-- ShredderWindow: "Шредер" — pick toys and recycle them into shards (frame, tabs, buttons: ShopKit). -- Tabs: Переработка / Ценность / Как это работает. -- Переработка : toy tiles (click = select, gold ring + tick), quick actions Выбрать всё / Обычные / Снять выбор, -- storage count. Right: selected count, shards you get, batch bonus, warning for rare toys. -- Button: off "Выбери игрушки" -> ready "Переработать" -> confirm "Точно? Нажми ещё раз" -- (only when legendary / mythic / special toys are selected) ; off "Шредер работает" while busy. -- Ценность : shards per rarity, variant multipliers, batch bonus, shredder upgrade. -- RemoteEvent Recycle:FireServer(machine, uids). getCards() is shared with the Workshop (fusion page). local K = require(script.Parent:WaitForChild("ShopKit")) local S = {} local WHITE, GOLD, SOFT, OK, WARN, BODY = K.WHITE, K.GOLD, K.SOFT, K.OK, K.WARN, K.BODY local new, corner, art, label, maxText, pill, tween = K.new, K.corner, K.art, K.label, K.maxText, K.pill, K.tween local ICE = Color3.fromRGB(190, 225, 255) function S.install(ctx) local Config, player, remote = ctx.Config, ctx.player, ctx.remote 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 BONUS = math.floor(Config.BATCH_BONUS * 100 + 0.5) local TABS = { { id = "Recycle", text = "Recycle", icon = "♻️", tip = Config.BATCH_SIZE .. "+ identical ornaments at once — bonus +" .. BONUS .. "% shards." }, { id = "Values", text = "Value", icon = "💎", tip = "Special ornaments (golden, shiny) are worth several times more." }, { id = "Help", text = "How It Works", icon = "📖", tip = "The shredder doesn't touch ornaments on the tree — take them down first." }, } local refresh local ch = K.chrome({ win = win, title = "SHREDDER", subtitle = "Turn extra ornaments\ninto shards", tabs = TABS, closeWindow = ctx.closeWindow, fmtNum = fmt, onTab = function() if win.overlay.Visible then refresh() end end }) local function darkPanel(parent, pos, size, z) return new("Frame", { Position = pos, Size = size, BackgroundColor3 = Color3.new(0, 0, 0), BackgroundTransparency = 0.5, ZIndex = z or 4, Parent = parent }, { corner(UDim.new(0, 22)), new("UIStroke", { Color = GOLD, Thickness = 2, Transparency = 0.4 }), }) end ---------------------------------------------------------------- recycle page local rg = ch.makePage("Recycle") local listPanel = darkPanel(rg, UDim2.fromOffset(0, 0), UDim2.fromOffset(820, 566)) local cards, selected, confirmArmed = {}, {}, nil local function selectWhere(pred) selected = {} local cand = {} for uid, c in cards do if pred(c) then table.insert(cand, { uid = uid, idx = c.rarity.Index + (c.item.Variant and 10 or 0) }) end end table.sort(cand, function(a, b) return a.idx < b.idx end) -- cheapest first for k = 1, math.min(#cand, Config.MAX_RECYCLE) do selected[cand[k].uid] = true end confirmArmed = nil refresh() end local allBtn = pill(listPanel, { Name = "SelectAll", Position = UDim2.fromOffset(12, 10), Size = UDim2.fromOffset(200, 56), ZIndex = 5, TextMax = 24 }, function() selectWhere(function() return true end) end) local commonBtn = pill(listPanel, { Name = "SelectCommon", Position = UDim2.fromOffset(218, 10), Size = UDim2.fromOffset(170, 56), ZIndex = 5, TextMax = 24 }, function() selectWhere(function(c) return c.rarity.Id == "Common" and not c.item.Variant end) end) local noneBtn = pill(listPanel, { Name = "SelectNone", Position = UDim2.fromOffset(394, 10), Size = UDim2.fromOffset(190, 56), ZIndex = 5, TextMax = 24 }, function() selected = {}; confirmArmed = nil; refresh() end) local stock = maxText(label({ Position = UDim2.fromOffset(596, 18), Size = UDim2.fromOffset(206, 40), Text = "", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 5, Parent = listPanel }, 2), 30) local grid = K.scroll(listPanel, UDim2.fromOffset(0, 74), UDim2.new(1, -4, 1, -80), new("UIGridLayout", { CellSize = UDim2.fromOffset(148, 196), CellPadding = UDim2.fromOffset(10, 10), SortOrder = Enum.SortOrder.LayoutOrder })) new("UIPadding", { PaddingLeft = UDim.new(0, 14), PaddingTop = UDim.new(0, 10), PaddingBottom = UDim.new(0, 10), Parent = grid }) local empty = K.emptyState({ Position = UDim2.fromOffset(0, 90), Size = UDim2.new(1, 0, 0, 330), ZIndex = 5, Parent = listPanel }, "No ornaments yet", "Make them in the generator and bring extras here.") -- right: summary + action local sum = darkPanel(rg, UDim2.fromOffset(840, 0), UDim2.fromOffset(420, 566)) maxText(label({ Position = UDim2.fromOffset(20, 12), Size = UDim2.fromOffset(380, 34), Text = "Selected", TextScaled = true, TextColor3 = SOFT, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = sum }, 2), 28) local selText = maxText(label({ Position = UDim2.fromOffset(20, 46), Size = UDim2.fromOffset(380, 64), Text = "0", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = sum }, 3), 56) maxText(label({ Position = UDim2.fromOffset(20, 118), Size = UDim2.fromOffset(380, 34), Text = "You get", TextScaled = true, TextColor3 = SOFT, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = sum }, 2), 28) local getPlate = art("blue", { Position = UDim2.fromOffset(60, 156), Size = UDim2.fromOffset(300, 92), ZIndex = 5, Parent = sum }) art("crystal", { Position = UDim2.fromOffset(-24, -8), Size = UDim2.fromOffset(104, 104), ZIndex = 6, Parent = getPlate }) local getText = maxText(label({ Position = UDim2.fromOffset(78, 14), Size = UDim2.new(1, -96, 1, -28), Text = "+0", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 6, Parent = getPlate }, 3), 46) local getScale = new("UIScale", { Parent = getPlate }) local batchText = maxText(label({ Position = UDim2.fromOffset(20, 262), Size = UDim2.fromOffset(380, 56), Text = "", TextScaled = true, TextWrapped = true, FontFace = BODY, TextColor3 = OK, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = sum }, 1.5), 22) local riskText = maxText(label({ Position = UDim2.fromOffset(20, 324), Size = UDim2.fromOffset(380, 70), Text = "", TextScaled = true, TextWrapped = true, TextColor3 = WARN, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = sum }, 2), 24) local maxNote = maxText(label({ Position = UDim2.fromOffset(20, 398), Size = UDim2.fromOffset(380, 40), Text = "", TextScaled = true, FontFace = BODY, TextColor3 = SOFT, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = sum }, 1.5), 20) local function selectedItems() local uids, items = {}, {} for uid in selected do local c = cards[uid] if c then table.insert(uids, uid); table.insert(items, c.item) end end return uids, items end local function isRisky(it) return Config.RarityById[it.Rarity].Index >= 5 or it.Variant ~= nil end local recBtn recBtn = pill(sum, { Name = "RecycleButton", Position = UDim2.fromOffset(20, 452), Size = UDim2.fromOffset(380, 96), ZIndex = 5, TextMax = 34 }, function(state) local uids, items = selectedItems() if #uids == 0 then return end local risky = false for _, it in items do if isRisky(it) then risky = true end end if risky and state ~= "confirm" then confirmArmed = true; refresh() return end local m = ctx.machine() if not m then ctx.toast("Go to your shredder", WARN) return end if m:GetAttribute("ShredderBusy") then ctx.toast("The shredder is still working, wait a couple of seconds", WARN) return end remote:FireServer(m, uids) selected = {} confirmArmed = nil ctx.closeWindow() refresh() end) -- tiles local function tileValue(data) return math.floor(Config.Value(data) * Config.ShredderMult(attr("Upg_Shredder", 0)) + 0.5) end local function addCard(item) local uid = item.Name if item:GetAttribute("OnTree") or cards[uid] then return end local data = { Toy = item:GetAttribute("Toy"), Rarity = item:GetAttribute("Rarity"), Variant = item:GetAttribute("Variant") } local toy, r = Config.ToyById[data.Toy], Config.RarityById[data.Rarity] if not toy or not r then return end local orderN = item:GetAttribute("Order") or 0 local t = K.toyTile({ Config = Config, miniPattern = ctx.miniPattern, parent = grid, item = data, w = 148, h = 196, z = 6, value = true, valueText = "+" .. fmt(tileValue(data)), order = (#Config.RARITIES - r.Index) * 1000000 - (data.Variant and 500000 or 0) - orderN }) local tick = new("Frame", { AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -6, 0, 6), Size = UDim2.fromOffset(38, 38), BackgroundColor3 = GOLD, Visible = false, ZIndex = 14, Parent = t.button }, { corner(UDim.new(0.5, 0)), new("UIStroke", { Color = K.INK, Thickness = 2 }), }) label({ Size = UDim2.fromScale(1, 1), Text = "✔️", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 15, Parent = tick }, 0) t.button.Activated:Connect(function() if selected[uid] then selected[uid] = nil else local n = 0 for _ in selected do n += 1 end if n >= Config.MAX_RECYCLE then t.wiggle() ctx.toast("You can recycle up to " .. Config.MAX_RECYCLE .. " ornaments", WARN) return end selected[uid] = true end confirmArmed = nil refresh() end) cards[uid] = { tile = t, tick = tick, item = data, rarity = r } end local function removeCard(item) local c = cards[item.Name] if c then c.tile.button:Destroy() end cards[item.Name] = nil selected[item.Name] = nil end local queued = false local function later() if queued then return end queued = true task.defer(function() queued = false; refresh() end) end local function watchInventory(inv) local function watchTree(item) item:GetAttributeChangedSignal("OnTree"):Connect(function() if item:GetAttribute("OnTree") then removeCard(item) else addCard(item) end later() end) end for _, item in inv:GetChildren() do watchTree(item); addCard(item) end inv.ChildAdded:Connect(function(item) watchTree(item) task.defer(function() addCard(item); later() end) end) inv.ChildRemoved:Connect(function(item) removeCard(item); later() end) later() end task.spawn(function() watchInventory(player:WaitForChild("OrnamentInventory")) end) -- the shredder upgrade changes every tile's value: rebuild them player:GetAttributeChangedSignal("Upg_Shredder"):Connect(function() local inv = player:FindFirstChild("OrnamentInventory") for _, c in cards do c.tile.button:Destroy() end cards = {} for _, item in inv and inv:GetChildren() or {} do addCard(item) end later() end) ---------------------------------------------------------------- values page local vg = ch.makePage("Values") local vaPanel = darkPanel(vg, UDim2.fromOffset(0, 0), UDim2.fromOffset(620, 566)) maxText(label({ Position = UDim2.fromOffset(20, 10), Size = UDim2.fromOffset(580, 38), Text = "Shards per ornament", TextScaled = true, ZIndex = 5, Parent = vaPanel }, 2), 32) maxText(label({ Position = UDim2.fromOffset(20, 52), Size = UDim2.fromOffset(580, 28), Text = "by rarity, before variant and ornament multipliers", TextScaled = true, FontFace = BODY, TextColor3 = SOFT, ZIndex = 5, Parent = vaPanel }, 1.5), 20) local valRows = {} for i, r in Config.RARITIES do local y = 92 + (i - 1) * 76 local row = new("Frame", { Position = UDim2.fromOffset(16, y), Size = UDim2.fromOffset(588, 66), BackgroundColor3 = Color3.fromRGB(12, 40, 52), ZIndex = 5, Parent = vaPanel }, { corner(UDim.new(0, 18)), new("UIStroke", { Color = r.Color, Thickness = 2, Transparency = 0.3 }), }) new("Frame", { AnchorPoint = Vector2.new(0, 0.5), Position = UDim2.new(0, 16, 0.5, 0), Size = UDim2.fromOffset(26, 26), BackgroundColor3 = r.Color, ZIndex = 6, Parent = row }, { corner(UDim.new(0.5, 0)) }) maxText(label({ Position = UDim2.fromOffset(56, 14), Size = UDim2.fromOffset(300, 38), Text = r.Name, TextScaled = true, TextColor3 = r.Color, ZIndex = 6, Parent = row }, 2), 30) valRows[i] = { r = r, t = maxText(label({ Position = UDim2.fromOffset(340, 14), Size = UDim2.fromOffset(230, 38), Text = "", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 6, Parent = row }, 2), 30) } end local moPanel = darkPanel(vg, UDim2.fromOffset(640, 0), UDim2.fromOffset(620, 566)) maxText(label({ Position = UDim2.fromOffset(20, 10), Size = UDim2.fromOffset(580, 38), Text = "Multipliers", TextScaled = true, ZIndex = 5, Parent = moPanel }, 2), 32) local lines = {} for _, v in Config.VARIANTS do table.insert(lines, { v.Name .. " ornament", "x" .. v.Mult, v.Color }) end for _, toy in Config.TOYS do if toy.Mult ~= 1 then table.insert(lines, { toy.Name, "x" .. toy.Mult, Color3.fromRGB(255, 205, 90) }) end end table.insert(lines, { Config.BATCH_SIZE .. "+ identical at once", "+" .. BONUS .. "%", OK }) local upgLine = #lines + 1 table.insert(lines, { "Shredder upgrade", "", ICE }) local upgText for i, l in lines do local y = 58 + (i - 1) * 46 if y > 520 then break end maxText(label({ Position = UDim2.fromOffset(24, y), Size = UDim2.fromOffset(400, 36), Text = l[1], TextScaled = true, FontFace = BODY, TextColor3 = l[3], ZIndex = 5, Parent = moPanel }, 1.5), 26) local t = maxText(label({ Position = UDim2.fromOffset(430, y), Size = UDim2.fromOffset(166, 36), Text = l[2], TextScaled = true, TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 5, Parent = moPanel }, 2), 28) if i == upgLine then upgText = t end end ---------------------------------------------------------------- help page 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 = "cardCyan", icon = "👆", title = "1. Select", btn = "To Ornaments", go = function() ch.showTab("Recycle") end, text = "Click ornaments or use “Select all” / “Common”. Up to " .. Config.MAX_RECYCLE .. " ornaments at once." }, { card = "cardViolet", icon = "♻️", title = "2. Recycle", btn = "Value", go = function() ch.showTab("Values") end, text = "Ornaments turn into shards. For rare and special ones the shredder asks to confirm — so you won't lose them by accident." }, { card = "cardOrange", icon = "⚡", title = "3. Upgrade", btn = "Workshop", go = function() K.go("Workshop", "Upgrades") end, text = "The shredder upgrade in the Workshop gives more shards from every ornament." }, } 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 }, h.go) go.set("alt", h.btn) end ---------------------------------------------------------------- refresh local lastGet = 0 refresh = function() ch.setBalance(attr("Shards", 0)) local uids, items = selectedItems() local shards = Config.RecycleYield(items, attr("Upg_Shredder", 0)) local risky, perToy = false, {} for _, it in items do if isRisky(it) then risky = true end perToy[it.Toy] = (perToy[it.Toy] or 0) + 1 end local batches = {} for toyId, n in perToy do if n >= Config.BATCH_SIZE then table.insert(batches, Config.ToyById[toyId].Name) end end local owned = 0 for uid, c in cards do owned += 1 local on = selected[uid] == true c.tile.setSelected(on) c.tick.Visible = on end stock.Text = owned .. " / " .. Config.StorageCap(attr("Upg_Storage", 0)) empty.Visible = owned == 0 selText.Text = tostring(#uids) maxNote.Text = #uids >= Config.MAX_RECYCLE and ("that's the max at once (" .. Config.MAX_RECYCLE .. ")") or "" getText.Text = "+" .. fmt(shards) if shards ~= lastGet and shards > 0 then getScale.Scale = 1.08 tween(getScale, 0.2, { Scale = 1 }, Enum.EasingStyle.Back) end lastGet = shards batchText.Text = #batches > 0 and ("Bonus +" .. BONUS .. "% for a batch: " .. table.concat(batches, ", ")) or (#uids > 0 and "" or "Click ornaments on the left to select them") riskText.Text = risky and "Your selection has legendary, mythic or special ornaments!" or "" -- quick actions if owned == 0 then allBtn.set("off", "Select all") else allBtn.set("alt", "Select all") end local anyCommon = false for _, c in cards do if c.rarity.Id == "Common" and not c.item.Variant then anyCommon = true break end end if anyCommon then commonBtn.set("alt", "Common") else commonBtn.set("off", "Common") end if #uids > 0 then noneBtn.set("alt", "Deselect") else noneBtn.set("off", "Deselect") end -- main button local m = ctx.machine() if #uids == 0 then recBtn.set("off", "Select ornaments") elseif m and m:GetAttribute("ShredderBusy") then recBtn.set("off", "Shredder working") elseif confirmArmed and risky then recBtn.set("confirm", "Sure? Click again") else recBtn.set("ready", "Recycle · " .. #uids) end -- values page local mult = Config.ShredderMult(attr("Upg_Shredder", 0)) for _, vr in valRows do vr.t.Text = fmt(math.floor(vr.r.Shards * mult + 0.5)) .. " shards" end if upgText then upgText.Text = string.format("x%.2f", mult) end end player:GetAttributeChangedSignal("Shards"):Connect(function() if win.overlay.Visible then ch.setBalance(attr("Shards", 0)) end end) ch.showTab("Recycle") return { open = function(tab) confirmArmed = nil ch.setBalance(attr("Shards", 0), true) if tab then ch.showTab(tab) end refresh() end, refresh = refresh, getCards = function() return cards end, showTab = ch.showTab, } end return S