315 lines
19 KiB
Luau
315 lines
19 KiB
Luau
-- InventoryWindow: "Инвентарь" — toys, plot items and boosters (frame, tabs, buttons: ShopKit).
|
|
-- Tabs: Игрушки / Предметы / Бустеры / Как это работает. "Предметы" shows a badge with bought items that are not
|
|
-- on the plot yet. Placing (ghost + R / Esc) and the toy-in-hand logic stay in OrnamentCraftUI; this module
|
|
-- calls them through ctx.startPlacing / ctx.storeDecor / ctx.toyCall.
|
|
local ContentProvider = game:GetService("ContentProvider")
|
|
local K = require(script.Parent:WaitForChild("ShopKit"))
|
|
|
|
local I = {}
|
|
|
|
local WHITE, GOLD, SOFT, OK, BODY, NAVY = K.WHITE, K.GOLD, K.SOFT, K.OK, K.BODY, K.NAVY
|
|
local new, corner, art, label, maxText, pill, chip, tween = K.new, K.corner, K.art, K.label, K.maxText, K.pill, K.chip, K.tween
|
|
local TOY_LIMIT = 120
|
|
|
|
local function viewport(parent, props)
|
|
props.BackgroundColor3 = Color3.fromRGB(8, 22, 30)
|
|
props.BackgroundTransparency = 0.25
|
|
props.Ambient = Color3.fromRGB(165, 165, 180)
|
|
props.LightColor = Color3.fromRGB(255, 245, 230)
|
|
props.LightDirection = Vector3.new(-1, -1.3, -1)
|
|
props.Parent = parent
|
|
return new("ViewportFrame", props, { corner(UDim.new(0, 18)) })
|
|
end
|
|
|
|
function I.install(ctx)
|
|
local Config, player = ctx.Config, ctx.player
|
|
local fmt = ctx.fmtNum
|
|
local function attr(n, d) local v = player:GetAttribute(n); if v == nil then return d end return v end
|
|
local win = ctx.win
|
|
local TABS = {
|
|
{ id = "Toys", text = "Ornaments", icon = "🎄", tip = "“Hold” it, then click a glowing dot on your tree to hang the ornament." },
|
|
{ id = "Items", text = "Items", icon = "🏠", tip = "“Place”: click to place, R to rotate, Esc to cancel." },
|
|
{ id = "Boosters", text = "Boosters", icon = "🍀", tip = "Put boosters in the generator slot before making an ornament." },
|
|
{ id = "Help", text = "How It Works", icon = "📖", tip = "Everything in your inventory is saved with your progress." },
|
|
}
|
|
local refresh
|
|
local ch = K.chrome({ win = win, title = "INVENTORY", subtitle = "Your ornaments, items\nand boosters", tabs = TABS,
|
|
closeWindow = ctx.closeWindow, fmtNum = fmt, onTab = function() if win.overlay.Visible then refresh() end end })
|
|
|
|
---------------------------------------------------------------- toys
|
|
local toysG = ch.makePage("Toys")
|
|
local toyFilter = "all"
|
|
local filterChips = {}
|
|
local filterRow = new("Frame", { Position = UDim2.fromOffset(4, 0), Size = UDim2.fromOffset(700, 54), BackgroundTransparency = 1, ZIndex = 4, Parent = toysG }, {
|
|
new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, Padding = UDim.new(0, 8), SortOrder = Enum.SortOrder.LayoutOrder, VerticalAlignment = Enum.VerticalAlignment.Center }),
|
|
})
|
|
for k, f in { { "all", "All" }, { "bag", "In inventory" }, { "tree", "On the tree" } } do
|
|
filterChips[k] = { id = f[1], o = chip(filterRow, { Size = UDim2.fromOffset(210, 50), LayoutOrder = k, ZIndex = 4 }, f[2], function() toyFilter = f[1]; refresh() end) }
|
|
end
|
|
local toyCount = maxText(label({ Position = UDim2.fromOffset(720, 8), Size = UDim2.fromOffset(530, 38), Text = "", TextScaled = true, FontFace = BODY, TextColor3 = SOFT,
|
|
TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 4, Parent = toysG }, 1.5), 22)
|
|
local toyGrid = K.scroll(toysG, UDim2.fromOffset(0, 64), UDim2.new(1, 0, 0, 502),
|
|
new("UIGridLayout", { CellSize = UDim2.fromOffset(238, 310), CellPadding = UDim2.fromOffset(12, 14), SortOrder = Enum.SortOrder.LayoutOrder }))
|
|
new("UIPadding", { PaddingLeft = UDim.new(0, 4), PaddingTop = UDim.new(0, 6), PaddingBottom = UDim.new(0, 6), Parent = toyGrid })
|
|
local toyEmpty
|
|
local toyBusy = {}
|
|
local function rebuildToys()
|
|
for _, c in toyGrid:GetChildren() do if c:IsA("GuiObject") then c:Destroy() end end
|
|
if toyEmpty then toyEmpty:Destroy(); toyEmpty = nil end
|
|
for _, c in filterChips do c.o.setSelected(c.id == toyFilter) end
|
|
local inv = player:FindFirstChild("OrnamentInventory")
|
|
local all = inv and inv:GetChildren() or {}
|
|
local onTree = 0
|
|
for _, c in all do if c:GetAttribute("OnTree") then onTree += 1 end end
|
|
toyCount.Text = #all .. " pcs · on the tree: " .. onTree .. " · storage: " .. Config.StorageCap(attr("Upg_Storage", 0))
|
|
local list = {}
|
|
for _, c in all do
|
|
local hung = c:GetAttribute("OnTree") ~= nil
|
|
if toyFilter == "all" or (toyFilter == "tree") == hung then table.insert(list, c) end
|
|
end
|
|
table.sort(list, function(x, y)
|
|
local tx, ty = x:GetAttribute("OnTree") ~= nil, y:GetAttribute("OnTree") ~= nil
|
|
if tx ~= ty then return tx end
|
|
local rx, ry = Config.RarityById[x:GetAttribute("Rarity")], Config.RarityById[y:GetAttribute("Rarity")]
|
|
if rx.Index ~= ry.Index then return rx.Index > ry.Index end
|
|
return (x:GetAttribute("Order") or 0) > (y:GetAttribute("Order") or 0)
|
|
end)
|
|
if #list == 0 then
|
|
toyEmpty = K.emptyState({ Position = UDim2.fromOffset(0, 80), Size = UDim2.new(1, 0, 0, 420), ZIndex = 4, Parent = toysG },
|
|
toyFilter == "tree" and "The tree is empty" or "No ornaments yet",
|
|
toyFilter == "tree" and "Hold an ornament and click a glowing dot on the tree." or "Make ornaments in the generator — they'll show up here.")
|
|
return
|
|
end
|
|
for k = 1, math.min(#list, TOY_LIMIT) do
|
|
local c = list[k]
|
|
local item = { Toy = c:GetAttribute("Toy"), Rarity = c:GetAttribute("Rarity"), Variant = c:GetAttribute("Variant") }
|
|
local r = Config.RarityById[item.Rarity]
|
|
local v = item.Variant and Config.VariantById[item.Variant]
|
|
local hung = c:GetAttribute("OnTree") ~= nil
|
|
local card = new("Frame", { BackgroundColor3 = WHITE, LayoutOrder = k, ZIndex = 5, Parent = toyGrid }, {
|
|
corner(UDim.new(0, 24)),
|
|
new("UIGradient", { Rotation = 90, Color = ColorSequence.new(r.Color:Lerp(Color3.new(0, 0, 0), 0.45), Color3.fromRGB(10, 22, 34)) }),
|
|
new("UIStroke", { Color = v and v.Color or r.Color, Thickness = v and 4 or 3 }),
|
|
})
|
|
local vp = viewport(card, { Position = UDim2.fromOffset(12, 12), Size = UDim2.new(1, -24, 0, 140), ZIndex = 6 })
|
|
local model = ctx.ToyModels.Build(item, 1)
|
|
model:PivotTo(CFrame.Angles(0, math.rad(25), 0))
|
|
model.Parent = vp
|
|
local cam = Instance.new("Camera")
|
|
cam.FieldOfView = 35
|
|
cam.CFrame = CFrame.lookAt(Vector3.new(0, 0.5, 4.2), Vector3.new(0, 0.15, 0))
|
|
cam.Parent = vp
|
|
vp.CurrentCamera = cam
|
|
if v then
|
|
local tag = new("Frame", { Position = UDim2.fromOffset(8, 8), Size = UDim2.fromOffset(104, 30), BackgroundColor3 = v.Color, ZIndex = 8, Parent = card }, { corner(UDim.new(0.5, 0)) })
|
|
maxText(label({ Position = UDim2.fromOffset(6, 3), Size = UDim2.new(1, -12, 1, -6), Text = v.Name, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 9, Parent = tag }, 1.5), 18)
|
|
end
|
|
maxText(label({ Position = UDim2.fromOffset(10, 158), Size = UDim2.new(1, -20, 0, 32), Text = Config.ToyById[item.Toy].Name, TextScaled = true,
|
|
TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 6, Parent = card }, 2.5), 30)
|
|
maxText(label({ Position = UDim2.fromOffset(10, 192), Size = UDim2.new(1, -20, 0, 24), Text = r.Name, TextScaled = true, TextColor3 = r.Color,
|
|
TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 6, Parent = card }, 2), 22)
|
|
maxText(label({ Position = UDim2.fromOffset(10, 218), Size = UDim2.new(1, -20, 0, 22), Text = hung and "on the tree" or ("in inventory · " .. Config.Value(item) .. " shards"), TextScaled = true,
|
|
FontFace = BODY, TextColor3 = hung and OK or SOFT, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 6, Parent = card }, 1.5), 18)
|
|
local btn
|
|
btn = pill(card, { Position = UDim2.fromOffset(14, 248), Size = UDim2.fromOffset(210, 52), ZIndex = 6, TextMax = 26 }, function()
|
|
toyBusy[c.Name] = true
|
|
btn.set("busy")
|
|
task.spawn(function()
|
|
local res = ctx.toyCall(hung and "TakeOff" or "Equip", c.Name)
|
|
toyBusy[c.Name] = nil
|
|
if res.ok and not hung then ctx.closeWindow() return end
|
|
if res.ok then K.floatText(card, "Taken down!") end
|
|
task.delay(0.2, function() if win.overlay.Visible and ch.current() == "Toys" then rebuildToys() end end)
|
|
end)
|
|
end)
|
|
if toyBusy[c.Name] then btn.set("busy")
|
|
elseif hung then btn.set("alt", "Take down")
|
|
else btn.set("ready", "Hold") end
|
|
end
|
|
if #list > TOY_LIMIT then
|
|
maxText(label({ Size = UDim2.fromOffset(238, 60), Text = "…and " .. (#list - TOY_LIMIT), TextScaled = true, TextColor3 = SOFT, TextXAlignment = Enum.TextXAlignment.Center,
|
|
LayoutOrder = TOY_LIMIT + 1, ZIndex = 5, Parent = toyGrid }, 1.5), 26)
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------- plot items
|
|
local _, itScroll = ch.makePage("Items", true)
|
|
new("UIGridLayout", { CellSize = UDim2.fromOffset(615, 272), CellPadding = UDim2.fromOffset(18, 18), SortOrder = Enum.SortOrder.LayoutOrder, Parent = itScroll })
|
|
new("UIPadding", { PaddingLeft = UDim.new(0, 2), PaddingTop = UDim.new(0, 2), Parent = itScroll })
|
|
local CARD_FOR = { Tree = "cardGreen", PullUpBar = "cardCyan", Bench = "cardViolet", Fireworks = "cardOrange", Garland = "cardViolet" }
|
|
local itemCards = {}
|
|
for _, it in Config.SHOP do
|
|
local card = art(CARD_FOR[it.Id] or "cardGreen", { LayoutOrder = it.Order, ScaleType = Enum.ScaleType.Slice, SliceCenter = K.CARD_SLICE, ZIndex = 4, Parent = itScroll })
|
|
local vp = viewport(card, { Position = UDim2.fromOffset(30, 46), Size = UDim2.fromOffset(220, 198), ZIndex = 5 })
|
|
task.spawn(function()
|
|
local template = ctx.decorTemplates:FindFirstChild(it.Model)
|
|
if not template then return end
|
|
local tree = it.OnTree and ctx.decorTemplates:FindFirstChild("ChristmasTree")
|
|
pcall(function() ContentProvider:PreloadAsync({ template, tree }) end) -- meshes must load before cloning
|
|
local model = template:Clone()
|
|
if tree then -- a tree item is shown on a tree
|
|
local both = Instance.new("Model")
|
|
local t = tree:Clone()
|
|
t:PivotTo(CFrame.new())
|
|
t.Parent = both
|
|
model:PivotTo(CFrame.new())
|
|
model.Parent = both
|
|
both.WorldPivot = CFrame.new() -- pivot at the tree's foot, not the box centre
|
|
model = both
|
|
end
|
|
model:PivotTo(CFrame.Angles(0, math.rad(-30), 0))
|
|
model.Parent = vp
|
|
local _, size = model:GetBoundingBox()
|
|
local cam = Instance.new("Camera")
|
|
cam.FieldOfView = 40
|
|
cam.CFrame = CFrame.lookAt(Vector3.new(0, size.Y * 0.62, math.max(size.X, size.Y, size.Z) * 1.5), Vector3.new(0, size.Y * 0.47, 0))
|
|
cam.Parent = vp
|
|
vp.CurrentCamera = cam
|
|
end)
|
|
maxText(label({ Position = UDim2.fromOffset(270, 40), Size = UDim2.fromOffset(320, 46), Text = it.Name, TextScaled = true, ZIndex = 5, Parent = card }, 3), 38)
|
|
local status = maxText(label({ Position = UDim2.fromOffset(272, 92), Size = UDim2.fromOffset(318, 30), Text = "", TextScaled = true, FontFace = BODY, ZIndex = 5, Parent = card }, 1.5), 22)
|
|
local hint = maxText(label({ Position = UDim2.fromOffset(272, 124), Size = UDim2.fromOffset(318, 56), Text = "", TextScaled = true, TextWrapped = true, FontFace = BODY,
|
|
TextColor3 = SOFT, TextYAlignment = Enum.TextYAlignment.Top, ZIndex = 5, Parent = card }, 1.5), 19)
|
|
local c = { it = it, card = card, status = status, hint = hint }
|
|
c.main = pill(card, { Position = UDim2.fromOffset(268, 188), Size = UDim2.fromOffset(196, 64), ZIndex = 5, TextMax = 26 }, function(state)
|
|
if not attr("Decor_" .. it.Id, false) then K.go("Shop", "All") return end
|
|
ctx.startPlacing(it.Id)
|
|
end)
|
|
c.second = pill(card, { Position = UDim2.fromOffset(472, 188), Size = UDim2.fromOffset(128, 64), ZIndex = 5, TextMax = 24 }, function()
|
|
c.second.set("busy")
|
|
task.spawn(function()
|
|
local res = ctx.storeDecor(it.Id)
|
|
if res.ok then K.floatText(card, "Removed") end
|
|
refresh()
|
|
end)
|
|
end)
|
|
itemCards[it.Id] = c
|
|
end
|
|
local function paintItems()
|
|
local waiting = 0
|
|
for id, c in itemCards do
|
|
local owned, placed = attr("Decor_" .. id, false), attr("Placed_" .. id, false)
|
|
c.card.ImageTransparency = owned and 0 or 0.35
|
|
if not owned then
|
|
c.status.Text, c.status.TextColor3 = "not bought yet", SOFT
|
|
c.hint.Text = "Shop price: " .. fmt(c.it.Price) .. " shards."
|
|
c.main.set("alt", "To Shop")
|
|
c.second.button.Visible = false
|
|
elseif placed and c.it.OnTree then
|
|
c.status.Text, c.status.TextColor3 = "on the tree", OK
|
|
c.hint.Text = "You can rewrap the tree or take the garland down."
|
|
c.main.set("alt", "Rehang")
|
|
c.second.button.Visible = true
|
|
if c.second.state ~= "busy" then c.second.set("danger", "Take down") end
|
|
elseif c.it.OnTree then
|
|
waiting += 1
|
|
c.status.Text, c.status.TextColor3 = "in inventory", GOLD
|
|
c.hint.Text = "Click the tree point by point — the garland follows your path."
|
|
c.main.set("ready", "Wrap the tree")
|
|
c.second.button.Visible = false
|
|
elseif placed then
|
|
c.status.Text, c.status.TextColor3 = "on your plot", OK
|
|
c.hint.Text = "You can move it or put it back in your inventory."
|
|
c.main.set("alt", "Move")
|
|
c.second.button.Visible = true
|
|
if c.second.state ~= "busy" then c.second.set("danger", "Store") end
|
|
else
|
|
waiting += 1
|
|
c.status.Text, c.status.TextColor3 = "in inventory", GOLD
|
|
c.hint.Text = "Pick a spot on your plot."
|
|
c.main.set("ready", "Place")
|
|
c.second.button.Visible = false
|
|
end
|
|
end
|
|
ch.tabs.Items.setBadge(waiting)
|
|
end
|
|
|
|
---------------------------------------------------------------- boosters
|
|
local _, boScroll = ch.makePage("Boosters", true)
|
|
new("UIGridLayout", { CellSize = UDim2.fromOffset(615, 470), CellPadding = UDim2.fromOffset(18, 18), SortOrder = Enum.SortOrder.LayoutOrder, Parent = boScroll })
|
|
new("UIPadding", { PaddingLeft = UDim.new(0, 2), PaddingTop = UDim.new(0, 2), Parent = boScroll })
|
|
local bOrder = {}
|
|
for id, b in Config.BOOSTERS do table.insert(bOrder, { id = id, b = b }) end
|
|
table.sort(bOrder, function(x, y) return x.b.Order < y.b.Order end)
|
|
local boCount = {}
|
|
for i, e in bOrder do
|
|
local card = art(i == 1 and "cardGreen" or "cardOrange", { LayoutOrder = i, ScaleType = Enum.ScaleType.Slice, SliceCenter = K.CARD_SLICE, ZIndex = 4, Parent = boScroll })
|
|
local orb = new("Frame", { AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 52), Size = UDim2.fromOffset(170, 170), BackgroundColor3 = e.b.Color, ZIndex = 5, Parent = card }, {
|
|
corner(UDim.new(0.5, 0)), new("UIStroke", { Color = WHITE, Thickness = 6 }),
|
|
new("UIGradient", { Rotation = 90, Color = ColorSequence.new(WHITE, Color3.fromRGB(170, 170, 170)) }),
|
|
})
|
|
label({ Size = UDim2.fromScale(1, 1), Text = "x" .. e.b.Luck, TextSize = 76, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 6, Parent = orb }, 4)
|
|
local cnt = new("Frame", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.new(1, 4, 0, 26), Size = UDim2.fromOffset(78, 78), BackgroundColor3 = NAVY, ZIndex = 7, Parent = orb }, {
|
|
corner(UDim.new(0.5, 0)), new("UIStroke", { Color = GOLD, Thickness = 4 }),
|
|
})
|
|
boCount[e.id] = maxText(label({ Position = UDim2.fromScale(0.12, 0.2), Size = UDim2.fromScale(0.76, 0.6), Text = "0", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 8, Parent = cnt }, 2), 38)
|
|
maxText(label({ Position = UDim2.fromOffset(30, 236), Size = UDim2.new(1, -60, 0, 50), Text = e.b.Name, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = card }, 3), 44)
|
|
maxText(label({ Position = UDim2.fromOffset(40, 288), Size = UDim2.new(1, -80, 0, 30), Text = "put it in the generator slot — one generation gets luck x" .. e.b.Luck, TextScaled = true, FontFace = BODY,
|
|
TextColor3 = SOFT, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = card }, 1.5), 22)
|
|
local a = pill(card, { Position = UDim2.fromOffset(40, 344), Size = UDim2.fromOffset(260, 76), ZIndex = 5, TextMax = 30 }, function() K.go("Workshop", "Boosters") end)
|
|
a.set("alt", "Craft more")
|
|
local b = pill(card, { Position = UDim2.fromOffset(316, 344), Size = UDim2.fromOffset(260, 76), ZIndex = 5, TextMax = 30 }, function() K.go("Premium", "Boosters") end)
|
|
b.set("ready", "For Robux")
|
|
end
|
|
|
|
---------------------------------------------------------------- help
|
|
local _, heScroll = ch.makePage("Help", true)
|
|
new("UIGridLayout", { CellSize = UDim2.fromOffset(404, 540), CellPadding = UDim2.fromOffset(20, 18), SortOrder = Enum.SortOrder.LayoutOrder, Parent = heScroll })
|
|
new("UIPadding", { PaddingLeft = UDim.new(0, 4), PaddingTop = UDim.new(0, 4), Parent = heScroll })
|
|
local HELP = {
|
|
{ card = "cardGreen", icon = "🎄", title = "Ornaments", tab = "Toys",
|
|
text = "“Hold” puts the ornament in your hand. Walk up to your tree and click a glowing dot to hang it." },
|
|
{ card = "cardViolet", icon = "🏠", title = "Items", tab = "Items",
|
|
text = "Things you buy in the shop go on your plot. Click to place, R to rotate, Esc to cancel." },
|
|
{ card = "cardOrange", icon = "🍀", title = "Boosters", tab = "Boosters",
|
|
text = "Boosters are crafted in the Workshop or bought for Robux. Put a booster in the generator slot." },
|
|
}
|
|
for i, h in HELP do
|
|
local card = art(h.card, { LayoutOrder = i, ScaleType = Enum.ScaleType.Slice, SliceCenter = K.CARD_SLICE, ZIndex = 4, Parent = heScroll })
|
|
label({ AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 44), Size = UDim2.fromOffset(120, 110), Text = h.icon, TextSize = 84, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = card }, 0)
|
|
maxText(label({ Position = UDim2.fromOffset(24, 160), Size = UDim2.new(1, -48, 0, 50), Text = h.title, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = card }, 3), 42)
|
|
maxText(label({ Position = UDim2.fromOffset(30, 218), Size = UDim2.new(1, -60, 0, 190), Text = h.text, TextScaled = true, TextWrapped = true, FontFace = BODY,
|
|
TextColor3 = WHITE, TextXAlignment = Enum.TextXAlignment.Center, TextYAlignment = Enum.TextYAlignment.Top, ZIndex = 5, Parent = card }, 1.5), 24)
|
|
local go = pill(card, { Position = UDim2.fromOffset(62, 420), Size = UDim2.fromOffset(280, 70), ZIndex = 5, TextMax = 30 }, function() ch.showTab(h.tab) end)
|
|
go.set("alt", "Open")
|
|
end
|
|
|
|
refresh = function()
|
|
ch.setBalance(attr("Shards", 0))
|
|
paintItems()
|
|
for id, t in boCount do t.Text = tostring(attr("Booster_" .. id, 0)) end
|
|
if ch.current() == "Toys" then rebuildToys() end
|
|
end
|
|
local function live() if win.overlay.Visible then refresh() end end
|
|
player:GetAttributeChangedSignal("Shards"):Connect(function() if win.overlay.Visible then ch.setBalance(attr("Shards", 0)) end end)
|
|
for _, it in Config.SHOP do
|
|
player:GetAttributeChangedSignal("Decor_" .. it.Id):Connect(live)
|
|
player:GetAttributeChangedSignal("Placed_" .. it.Id):Connect(live)
|
|
end
|
|
for id in Config.BOOSTERS do player:GetAttributeChangedSignal("Booster_" .. id):Connect(live) end
|
|
task.spawn(function()
|
|
local inv = player:WaitForChild("OrnamentInventory")
|
|
local queued = false
|
|
local function changed()
|
|
if queued or not (win.overlay.Visible and ch.current() == "Toys") then return end
|
|
queued = true
|
|
task.delay(0.15, function() queued = false; rebuildToys() end)
|
|
end
|
|
inv.ChildAdded:Connect(changed)
|
|
inv.ChildRemoved:Connect(changed)
|
|
local function watchToy(c) c:GetAttributeChangedSignal("OnTree"):Connect(changed) end
|
|
for _, c in inv:GetChildren() do watchToy(c) end
|
|
inv.ChildAdded:Connect(watchToy)
|
|
end)
|
|
ch.showTab("Toys")
|
|
return {
|
|
open = function(tab)
|
|
ch.setBalance(attr("Shards", 0), true)
|
|
if tab and tab ~= ch.current() then ch.showTab(tab) else refresh() end
|
|
end,
|
|
showTab = ch.showTab,
|
|
}
|
|
end
|
|
|
|
return I
|