Files
Ornament-Generator-RNG/GUI/generator_original.luau
T
2026-11-16 23:50:40 +03:00

1653 lines
97 KiB
Luau
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- Ornament game UI (economy phase 1, shards are the only resource):
-- * HUD: level + XP bar, shards (with free regeneration timer)
-- * generator menu (E near the generator or a click on it): 4x4 shard grid, booster slot, luck + rarity
-- chances, pity counters, drop pool, and the "Создать игрушку" button that starts the generation
-- * shredder menu (shredder button, "Открыть шредер"): pick toys and recycle them into shards
-- All state comes from player attributes / player.OrnamentInventory; this script only sends requests.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ProximityPromptService = game:GetService("ProximityPromptService")
local TweenService = game:GetService("TweenService")
local player = Players.LocalPlayer
local folder = ReplicatedStorage:WaitForChild("OrnamentMachine")
local Config = require(folder:WaitForChild("Config"))
local craftRemote = folder:WaitForChild("CraftAction")
local notifyRemote = folder:WaitForChild("Notify")
local recycleRemote = folder:WaitForChild("Recycle")
local NAVY = Color3.fromRGB(16, 24, 48)
local PANEL = Color3.fromRGB(24, 34, 64)
local SLOT = Color3.fromRGB(36, 50, 90)
local SLOT_ON = Color3.fromRGB(46, 74, 128)
local EDGE = Color3.fromRGB(80, 105, 160)
local GOLD = Color3.fromRGB(255, 200, 90)
local RED = Color3.fromRGB(185, 30, 42)
local GREEN = Color3.fromRGB(38, 140, 66)
local ICE = Color3.fromRGB(150, 205, 255)
local COIN = Color3.fromRGB(255, 205, 70)
local SPARK = Color3.fromRGB(255, 120, 200)
local WHITE = Color3.new(1, 1, 1)
local MUTED = Color3.fromRGB(165, 180, 212)
local WARN = Color3.fromRGB(255, 120, 110)
local OK = Color3.fromRGB(140, 255, 160)
local BOLD, REGULAR = Enum.Font.GothamBold, Enum.Font.Gotham
---------------------------------------------------------------- helpers
local function new(class, props, children)
local o = Instance.new(class)
for k, v in props do
if k ~= "Parent" then o[k] = v end
end
for _, c in children or {} do c.Parent = o end
if props.Parent then o.Parent = props.Parent end
return o
end
local function corner(r) return new("UICorner", { CornerRadius = UDim.new(0, r) }) end
local function stroke(color, thickness)
return new("UIStroke", { Color = color, Thickness = thickness or 2, ApplyStrokeMode = Enum.ApplyStrokeMode.Border })
end
local function text(props)
props.BackgroundTransparency = 1
props.Font = props.Font or BOLD
props.TextColor3 = props.TextColor3 or WHITE
if props.TextXAlignment == nil then props.TextXAlignment = Enum.TextXAlignment.Left end
return new("TextLabel", props)
end
local function button(props, color)
props.BackgroundColor3 = color
props.Font = props.Font or BOLD
props.TextColor3 = props.TextColor3 or WHITE
props.AutoButtonColor = true
return new("TextButton", props, { corner(10), stroke(GOLD, 2) })
end
local function gem(size, parent, c1, c2)
local holder = new("Frame", { Size = UDim2.fromOffset(size, size), BackgroundTransparency = 1, Parent = parent })
new("Frame", {
AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Size = UDim2.fromScale(0.6, 0.6),
Rotation = 45, BackgroundColor3 = WHITE, Parent = holder,
}, {
corner(math.max(2, math.floor(size * 0.08))),
new("UIStroke", { Color = Color3.fromRGB(240, 248, 255), Thickness = 1.5 }),
new("UIGradient", { Color = ColorSequence.new(c1, c2), Rotation = 90 }),
})
return holder
end
local function shardIcon(size, parent) return gem(size, parent, Color3.fromRGB(235, 248, 255), Color3.fromRGB(85, 145, 255)) end
local function sparkIcon(size, parent) return gem(size, parent, Color3.fromRGB(255, 230, 245), SPARK) end
local function coinIcon(size, parent)
return new("Frame", { Size = UDim2.fromOffset(size, size), BackgroundColor3 = COIN, Parent = parent }, {
corner(size), new("UIStroke", { Color = Color3.fromRGB(200, 130, 20), Thickness = 2 }),
text({ Size = UDim2.fromScale(1, 1), Text = "$", TextSize = math.floor(size * 0.6), TextColor3 = Color3.fromRGB(150, 90, 10), TextXAlignment = Enum.TextXAlignment.Center }),
})
end
local function miniPattern(mask, color, size, parent)
local cell = math.floor((size - 3) / 4)
local g = new("Frame", { Size = UDim2.fromOffset(size, size), BackgroundTransparency = 1, Parent = parent }, {
new("UIGridLayout", { CellSize = UDim2.fromOffset(cell, cell), CellPadding = UDim2.fromOffset(1, 1), SortOrder = Enum.SortOrder.LayoutOrder }),
})
for c = 1, Config.SLOT_COUNT do
local on = mask:sub(c, c) == "1"
new("Frame", { BackgroundColor3 = on and color or Color3.fromRGB(50, 66, 108), BackgroundTransparency = on and 0 or 0.3, BorderSizePixel = 0, LayoutOrder = c, Parent = g }, { corner(2) })
end
return g
end
local function fmtPct(p)
p *= 100
if p >= 10 then return string.format("%.0f%%", p) end
if p >= 0.1 then return string.format("%.1f%%", p) end
return string.format("%.2f%%", p)
end
local function fmtNum(n)
local s = tostring(math.floor(n))
local out = s:reverse():gsub("(%d%d%d)", "%1 "):reverse()
return (out:gsub("^ ", ""))
end
local function attr(name, default) local v = player:GetAttribute(name); if v == nil then return default end return v end
local gui = new("ScreenGui", {
Name = "OrnamentCraftGui", ResetOnSpawn = false, ZIndexBehavior = Enum.ZIndexBehavior.Sibling,
Parent = player:WaitForChild("PlayerGui"),
})
---------------------------------------------------------------- HUD
local hudStack = new("Frame", { Name = "Hud", Position = UDim2.new(0, 14, 0, 66), Size = UDim2.fromOffset(210, 240), BackgroundTransparency = 1, Parent = gui }, {
new("UIListLayout", { Padding = UDim.new(0, 6), SortOrder = Enum.SortOrder.LayoutOrder }),
})
local function hudRow(order, height)
return new("Frame", { Size = UDim2.fromOffset(210, height), BackgroundColor3 = NAVY, BackgroundTransparency = 0.08, LayoutOrder = order, Parent = hudStack }, { corner(12), stroke(GOLD, 2) })
end
local levelRow = hudRow(1, 48)
local levelText = text({ Position = UDim2.fromOffset(12, 4), Size = UDim2.new(1, -24, 0, 20), Text = "Level 1", TextSize = 17, Parent = levelRow })
local xpText = text({ Position = UDim2.fromOffset(12, 4), Size = UDim2.new(1, -24, 0, 20), Text = "", TextSize = 12, Font = REGULAR, TextColor3 = MUTED, TextXAlignment = Enum.TextXAlignment.Right, Parent = levelRow })
local xpBar = new("Frame", { Position = UDim2.fromOffset(12, 30), Size = UDim2.new(1, -24, 0, 9), BackgroundColor3 = Color3.fromRGB(40, 54, 92), Parent = levelRow }, { corner(5) })
local xpFill = new("Frame", { Size = UDim2.fromScale(0, 1), BackgroundColor3 = OK, Parent = xpBar }, { corner(5) })
local shardRow = hudRow(2, 52)
shardIcon(40, shardRow).Position = UDim2.fromOffset(8, 6)
local shardCount = text({ Position = UDim2.fromOffset(54, 4), Size = UDim2.new(1, -62, 0, 26), Text = "0", TextSize = 24, Parent = shardRow })
local shardCaption = text({ Position = UDim2.fromOffset(54, 30), Size = UDim2.new(1, -62, 0, 16), Text = "осколки", TextSize = 12, Font = REGULAR, TextColor3 = MUTED, Parent = shardRow })
local function floatDelta(row, amount)
local t = text({
Position = UDim2.new(1, 8, 0, 8), Size = UDim2.fromOffset(90, 26), Text = (amount > 0 and "+" or "-") .. fmtNum(math.abs(amount)),
TextSize = 22, TextColor3 = amount > 0 and OK or WARN, Parent = row,
})
TweenService:Create(t, TweenInfo.new(1.2), { Position = UDim2.new(1, 8, 0, -16), TextTransparency = 1 }):Play()
task.delay(1.3, function() t:Destroy() end)
end
local last = {}
local function trackDelta(name, row)
local v = player:GetAttribute(name)
if v ~= nil and last[name] ~= nil and v ~= last[name] then floatDelta(row, v - last[name]) end
last[name] = v
end
local function updateHud()
local level, xp, need = attr("Level", 1), attr("XP", 0), attr("XPNeed", 0)
levelText.Text = "Level " .. level
xpText.Text = need > 0 and (fmtNum(xp) .. " / " .. fmtNum(need) .. " XP") or "max"
xpFill.Size = UDim2.fromScale(need > 0 and math.clamp(xp / need, 0, 1) or 1, 1)
shardCount.Text = fmtNum(attr("Shards", 0))
trackDelta("Shards", shardRow)
end
local function updateRegen()
local at = attr("ShardRegenAt", 0)
if at == 0 then
shardCaption.Text = "запас полон (" .. attr("ShardCap", Config.REGEN_CAP) .. ")"
else
local left = math.max(0, at - os.time())
shardCaption.Text = string.format("+1 через %d:%02d", left // 60, left % 60)
end
end
for _, name in { "Level", "XP", "XPNeed", "Shards" } do
player:GetAttributeChangedSignal(name):Connect(updateHud)
end
updateHud()
task.spawn(function()
while true do
updateRegen()
task.wait(1)
end
end)
---------------------------------------------------------------- toasts
local toasts = new("Frame", {
AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 74), Size = UDim2.new(0, 460, 0, 320),
BackgroundTransparency = 1, Parent = gui,
}, { new("UIListLayout", { HorizontalAlignment = Enum.HorizontalAlignment.Center, Padding = UDim.new(0, 8), SortOrder = Enum.SortOrder.LayoutOrder }) })
local toastOrder = 0
local function toast(message, color, big)
toastOrder -= 1
local frame = new("Frame", {
Size = UDim2.fromOffset(big and 460 or 400, big and 62 or 48), BackgroundColor3 = NAVY,
BackgroundTransparency = 0.05, LayoutOrder = toastOrder, Parent = toasts,
}, { corner(12) })
local st = stroke(color or GOLD, big and 3 or 2)
st.Parent = frame
local l = text({
Position = UDim2.fromOffset(12, 0), Size = UDim2.new(1, -24, 1, 0), Text = message, TextWrapped = true,
TextSize = big and 20 or 15, TextColor3 = big and (color or WHITE) or WHITE, TextXAlignment = Enum.TextXAlignment.Center, Parent = frame,
})
task.delay(big and 4.5 or 3.2, function()
local info = TweenInfo.new(0.4)
TweenService:Create(frame, info, { BackgroundTransparency = 1 }):Play()
TweenService:Create(l, info, { TextTransparency = 1 }):Play()
TweenService:Create(st, info, { Transparency = 1 }):Play()
task.wait(0.45)
frame:Destroy()
end)
end
---------------------------------------------------------------- window helper
local openMenu -- { overlay, machine }
local placingDecor = false -- true while the player is placing a decoration (blocks other clicks / E)
local function makeWindow(name, title, w, h, titleColor)
local overlay = new("Frame", {
Name = name, Size = UDim2.fromScale(1, 1), BackgroundColor3 = Color3.new(0, 0, 0),
BackgroundTransparency = 0.45, Visible = false, Active = true, ZIndex = 5, Parent = gui,
})
local panel = new("Frame", {
Name = "Panel", AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Size = UDim2.fromOffset(w, h),
BackgroundColor3 = PANEL, Parent = overlay,
}, { corner(18), stroke(GOLD, 3) })
local scale = new("UIScale", { Parent = panel })
local bar = new("Frame", { Size = UDim2.new(1, 0, 0, 58), BackgroundColor3 = titleColor, Parent = panel }, { corner(18) })
new("Frame", { Position = UDim2.new(0, 0, 1, -18), Size = UDim2.new(1, 0, 0, 18), BackgroundColor3 = titleColor, BorderSizePixel = 0, Parent = bar })
text({ Position = UDim2.fromOffset(24, 0), Size = UDim2.new(1, -100, 1, 0), Text = title, TextSize = 26, Parent = bar })
local close = button({
Name = "Close", AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -12, 0.5, 0), Size = UDim2.fromOffset(42, 42),
Text = "X", TextSize = 22, Parent = bar,
}, titleColor:Lerp(Color3.new(0, 0, 0), 0.3))
local win = { overlay = overlay, panel = panel, scale = scale, w = w, h = h }
close.Activated:Connect(function() if openMenu == win then openMenu = nil end overlay.Visible = false; ProximityPromptService.Enabled = true end)
return win
end
local function openWindow(win, machine, onOpen)
if openMenu then openMenu.overlay.Visible = false end
openMenu = win
win.machine = machine
local v = workspace.CurrentCamera.ViewportSize
local inset = game:GetService("GuiService"):GetGuiInset() -- the GUI area starts under the top bar
win.scale.Scale = math.clamp(math.min((v.X - 24) / win.w, (v.Y - inset.Y - 24) / win.h), 0.4, 1.15)
win.overlay.Visible = true
ProximityPromptService.Enabled = false
if onOpen then onOpen() end
end
local function closeWindow()
if openMenu then openMenu.overlay.Visible = false end
openMenu = nil
ProximityPromptService.Enabled = true
end
task.spawn(function() -- close menus when the player walks away from the machine
while true do
task.wait(0.5)
if openMenu and openMenu.machine then
local hrp = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
if not openMenu.machine.Parent or (hrp and (hrp.Position - openMenu.machine:GetPivot().Position).Magnitude > 35) then
closeWindow()
end
end
end
end)
---------------------------------------------------------------- New Year window art (GUI/новогодние_окна)
-- Templates are 1448 x 1086. artify(win, image) turns a makeWindow() window into its template: the panel shows
-- the art and is 1448 x 1086 "template pixels", so content is laid out in the template's own coordinates
-- (openWindow's UIScale fits it to the screen). One table = one local (the script is at Luau's 200-local limit).
local ArtUI = {
W = 1448, H = 1086,
IMG = {
inventory = "rbxassetid://133163187725665",
market = "rbxassetid://104365529018018",
premium = "rbxassetid://133734122560497",
trade = "rbxassetid://113021404006859",
workshop_upgrades = "rbxassetid://96976290741467",
workshop_boosters = "rbxassetid://95007095222440",
generator = "rbxassetid://85887804948940", -- generator_bg.png (1536 x 1024)
shredder = "rbxassetid://110267441206876", -- shredder_bg.png (1536 x 1024)
},
-- transparent pill buttons (id, opaque rect of the source png)
PILL = {
purple = { "rbxassetid://117350842514434", nil },
green = { "rbxassetid://93987797017793", { 16, 110, 280, 102 } },
red = { "rbxassetid://138508596098174", { 18, 108, 280, 102 } },
cyan = { "rbxassetid://111888989174975", { 18, 114, 278, 94 } },
gold = { "rbxassetid://131564766133063", { 16, 108, 280, 102 } },
grey = { "rbxassetid://89653402754634", { 16, 108, 280, 102 } },
},
FONT = Font.new("rbxasset://fonts/families/FredokaOne.json", Enum.FontWeight.Bold),
INK = Color3.fromRGB(12, 8, 10),
GREENROW = Color3.fromRGB(16, 70, 44),
}
function ArtUI.setPill(img, kind)
local d = ArtUI.PILL[kind]
img.Image = d[1]
if d[2] then
img.ImageRectOffset = Vector2.new(d[2][1], d[2][2])
img.ImageRectSize = Vector2.new(d[2][3], d[2][4])
else
img.ImageRectOffset = Vector2.zero
img.ImageRectSize = Vector2.zero
end
end
-- rounded bold text with a thin black outline (like the art)
function ArtUI.label(props, strokeThickness)
local t = text(props)
t.FontFace = ArtUI.FONT
new("UIStroke", { Color = ArtUI.INK, Thickness = strokeThickness or 2, Parent = t })
return t
end
-- pill ImageButton with a centred caption (caption: b.Caption)
function ArtUI.pillButton(props, kind, caption, textSize)
props.BackgroundTransparency = 1
props.AutoButtonColor = true
local b = new("ImageButton", props)
ArtUI.setPill(b, kind)
ArtUI.label({ Name = "Caption", Position = UDim2.fromScale(0.07, 0.16), Size = UDim2.fromScale(0.86, 0.68), Text = caption or "",
TextSize = textSize or 32, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 3, Parent = b })
return b
end
-- action button over a baked purple pill (art rows) or with its own pill; grey overlay when disabled
function ArtUI.actionButton(parent, ownPill, kind)
local b = new("ImageButton", { BackgroundTransparency = 1, AutoButtonColor = true, Parent = parent })
if ownPill then ArtUI.setPill(b, kind or "purple") end
local grey = new("ImageLabel", { Name = "Grey", Position = UDim2.fromOffset(-9, -9), Size = UDim2.new(1, 18, 1, 18), BackgroundTransparency = 1, Visible = false, ZIndex = 2, Parent = b })
ArtUI.setPill(grey, "grey")
local cap = ArtUI.label({ Name = "Caption", Position = UDim2.fromScale(0.07, 0.17), Size = UDim2.fromScale(0.86, 0.66), Text = "",
TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 3, Parent = b })
new("UITextSizeConstraint", { MaxTextSize = 30, Parent = cap })
return b
end
-- load every template up front (otherwise a tab switch shows an empty window for a moment)
task.spawn(function()
local tmp = {}
for _, id in ArtUI.IMG do table.insert(tmp, new("ImageLabel", { Image = id })) end
for _, d in ArtUI.PILL do table.insert(tmp, new("ImageLabel", { Image = d[1] })) end
pcall(function() game:GetService("ContentProvider"):PreloadAsync(tmp) end)
end)
-- the pill that matches the colour a button() was given
function ArtUI.kindOf(c)
local best, bd = "green", math.huge
for kind, ref in { green = Color3.fromRGB(38, 140, 66), red = Color3.fromRGB(185, 30, 42), grey = Color3.fromRGB(70, 82, 120),
gold = Color3.fromRGB(165, 100, 20), cyan = Color3.fromRGB(30, 130, 140), purple = Color3.fromRGB(110, 60, 170) } do
local d = (c.R - ref.R) ^ 2 + (c.G - ref.G) ^ 2 + (c.B - ref.B) ^ 2
if d < bd then best, bd = kind, d end
end
return best
end
-- re-skins a plain button() as an art pill with a big outlined caption. The caption follows btn.Text, the pill
-- follows btn.BackgroundColor3 (green / red / grey / gold / cyan / purple); an inactive button is grey.
function ArtUI.skin(btn, maxText)
btn.BackgroundTransparency = 1
btn.TextTransparency = 1
for _, c in btn:GetChildren() do if c:IsA("UIStroke") then c.Enabled = false end end
local pill = new("ImageLabel", { Name = "Pill", Position = UDim2.fromOffset(-4, -4), Size = UDim2.new(1, 8, 1, 8), BackgroundTransparency = 1, ZIndex = btn.ZIndex, Parent = btn })
local cap = ArtUI.label({ Name = "Caption", Position = UDim2.fromScale(0.08, 0.17), Size = UDim2.fromScale(0.84, 0.66), Text = btn.Text, TextScaled = true,
TextXAlignment = Enum.TextXAlignment.Center, ZIndex = btn.ZIndex + 1, Parent = btn })
new("UITextSizeConstraint", { MaxTextSize = maxText or 30, Parent = cap })
local function paint()
ArtUI.setPill(pill, btn.Active and ArtUI.kindOf(btn.BackgroundColor3) or "grey")
cap.Text = btn.Text
end
btn:GetPropertyChangedSignal("Text"):Connect(paint)
btn:GetPropertyChangedSignal("BackgroundColor3"):Connect(paint)
btn:GetPropertyChangedSignal("Active"):Connect(paint)
btn:GetPropertyChangedSignal("BackgroundTransparency"):Connect(function() if btn.BackgroundTransparency ~= 1 then btn.BackgroundTransparency = 1 end end)
btn:GetPropertyChangedSignal("TextTransparency"):Connect(function() if btn.TextTransparency ~= 1 then btn.TextTransparency = 1 end end)
paint()
return btn
end
function ArtUI.artify(win, image, w, h, closeRect)
local p = win.panel
w, h = w or ArtUI.W, h or ArtUI.H
closeRect = closeRect or { 1309, 59, 106, 97 }
win.w, win.h = w, h
p.Size = UDim2.fromOffset(w, h)
p.BackgroundTransparency = 1
for _, c in p:GetChildren() do
if c:IsA("UIStroke") then c.Enabled = false end
if c:IsA("Frame") and c.Size.Y.Offset == 58 then c.Visible = false end -- the old title bar
end
local art = new("ImageLabel", { Name = "Art", Size = UDim2.fromScale(1, 1), BackgroundTransparency = 1, Image = image, ZIndex = 0, Parent = p })
local close = new("TextButton", { Name = "ArtClose", Text = "", BackgroundTransparency = 1, Position = UDim2.fromOffset(closeRect[1], closeRect[2]), Size = UDim2.fromOffset(closeRect[3], closeRect[4]), ZIndex = 8, Parent = p })
close.Activated:Connect(function() closeWindow() end)
return art
end
---------------------------------------------------------------- crafting menu
local W, H, MAIN_W = 920, 590, 680
local craft = makeWindow("CraftMenu", "Ornament Generator", W, H, RED)
local panel = craft.panel
-- art: generator_bg (template pixels): 4x4 shard cells, booster slot + 2 booster rows, 6 drop rows
ArtUI.artify(craft, ArtUI.IMG.generator, 1536, 1024, { 1403, 40, 107, 87 })
local SOFTG = Color3.fromRGB(215, 230, 220)
local inGridLabel = ArtUI.label({ Position = UDim2.fromOffset(300, 256), Size = UDim2.fromOffset(235, 32), Text = "", TextScaled = true, TextColor3 = Color3.fromRGB(215, 230, 220), TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 4, Parent = panel }, 1.5)
new("UITextSizeConstraint", { MaxTextSize = 26, Parent = inGridLabel })
local COL_X, ROW_Y, CELL = { 56, 177, 298, 419 }, { 293, 415, 538, 661 }, 113
local CRYSTAL_ID, CRYSTAL_RECT = "rbxassetid://105804941618750", { 54, 56, 206, 210 }
local slots = {}
for i = 1, Config.SLOT_COUNT do
local cx, cy = COL_X[(i - 1) % 4 + 1], ROW_Y[(i - 1) // 4 + 1]
local b = new("TextButton", { Text = "", BackgroundTransparency = 1, AutoButtonColor = false, Position = UDim2.fromOffset(cx, cy), Size = UDim2.fromOffset(CELL, CELL), ZIndex = 3, Parent = panel }, { corner(20) })
local st = new("UIStroke", { Color = ICE, Thickness = 0, ApplyStrokeMode = Enum.ApplyStrokeMode.Border, Parent = b })
local icon = new("ImageLabel", { BackgroundTransparency = 1, Image = CRYSTAL_ID, ImageRectOffset = Vector2.new(CRYSTAL_RECT[1], CRYSTAL_RECT[2]), ImageRectSize = Vector2.new(CRYSTAL_RECT[3], CRYSTAL_RECT[4]),
AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Size = UDim2.fromOffset(80, 82), Visible = false, ZIndex = 4, Parent = b })
b.Activated:Connect(function() craftRemote:FireServer("Slot", i) end)
slots[i] = { button = b, stroke = st, icon = icon }
end
local fillBtn = button({ Name = "Autofill", Position = UDim2.fromOffset(56, 796), Size = UDim2.fromOffset(234, 68), Text = "Auto Pattern", TextSize = 30, ZIndex = 3, Parent = panel }, GREEN)
local clearBtn = button({ Name = "Clear", Position = UDim2.fromOffset(299, 796), Size = UDim2.fromOffset(236, 68), Text = "Clear", TextSize = 30, ZIndex = 3, Parent = panel }, Color3.fromRGB(30, 130, 140))
local generateRemote = folder:WaitForChild("Generate")
local generateBtn = button({ Name = "GenerateButton", Position = UDim2.fromOffset(63, 875), Size = UDim2.fromOffset(470, 81), Text = "Создать игрушку", TextSize = 40, ZIndex = 3, Parent = panel }, RED)
ArtUI.skin(fillBtn, 32)
ArtUI.skin(clearBtn, 32)
ArtUI.skin(generateBtn, 44)
fillBtn.Activated:Connect(function() craftRemote:FireServer("Fill") end)
clearBtn.Activated:Connect(function() craftRemote:FireServer("Clear") end)
-- booster slot (baked square) + info + 2 baked booster rows
local boosterSlot = new("TextButton", { Position = UDim2.fromOffset(575, 292), Size = UDim2.fromOffset(177, 175), Text = "", BackgroundTransparency = 1, AutoButtonColor = false, ZIndex = 3, Parent = panel }, { corner(24) })
local boosterStroke = new("UIStroke", { Color = GOLD, Thickness = 0, ApplyStrokeMode = Enum.ApplyStrokeMode.Border, Parent = boosterSlot })
local boosterSlotText = ArtUI.label({ Position = UDim2.fromScale(0.06, 0.06), Size = UDim2.fromScale(0.88, 0.88), Text = "+", TextSize = 70, TextColor3 = SOFTG, TextWrapped = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 4, Parent = boosterSlot })
local boosterInfo = ArtUI.label({ Position = UDim2.fromOffset(768, 296), Size = UDim2.fromOffset(245, 168), Text = "", TextSize = 22, TextColor3 = SOFTG, TextWrapped = true, TextYAlignment = Enum.TextYAlignment.Top, ZIndex = 3, Parent = panel }, 1.5)
boosterSlot.Activated:Connect(function() craftRemote:FireServer("Booster", nil) end)
local BOOST_ROWS = { { 575, 485, 435, 77 }, { 575, 577, 435, 76 } }
local boosterRows = {}
for id, b in Config.BOOSTERS do
local r = BOOST_ROWS[b.Order] or BOOST_ROWS[2]
local row = new("TextButton", { Position = UDim2.fromOffset(r[1], r[2]), Size = UDim2.fromOffset(r[3], r[4]), Text = "", BackgroundTransparency = 1, AutoButtonColor = false, ZIndex = 3, Parent = panel }, { corner(22) })
local st = new("UIStroke", { Color = GOLD, Thickness = 0, ApplyStrokeMode = Enum.ApplyStrokeMode.Border, Parent = row })
local orb = new("Frame", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromOffset(42, r[4] / 2), Size = UDim2.fromOffset(50, 50), BackgroundColor3 = b.Color, ZIndex = 4, Parent = row }, { corner(25) })
ArtUI.label({ Size = UDim2.fromScale(1, 1), Text = "x" .. b.Luck, TextSize = 24, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = orb }, 1.5)
ArtUI.label({ Position = UDim2.fromOffset(88, 0), Size = UDim2.new(1, -190, 1, 0), Text = b.Name, TextSize = 30, ZIndex = 4, Parent = row })
local count = ArtUI.label({ AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -20, 0, 0), Size = UDim2.new(0, 100, 1, 0), Text = "x0", TextSize = 32, TextColor3 = GOLD, TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 4, Parent = row })
row.Activated:Connect(function() craftRemote:FireServer("Booster", id) end)
boosterRows[id] = { row = row, stroke = st, count = count }
end
-- luck, chances, pity: the free lower part of the middle column
local luckLabel = ArtUI.label({ Position = UDim2.fromOffset(582, 668), Size = UDim2.fromOffset(430, 42), Text = "", TextScaled = true, TextColor3 = GOLD, ZIndex = 3, Parent = panel })
new("UITextSizeConstraint", { MaxTextSize = 34, Parent = luckLabel })
local chancesBox = new("Frame", { Position = UDim2.fromOffset(582, 716), Size = UDim2.fromOffset(430, 104), BackgroundTransparency = 1, ZIndex = 3, Parent = panel }, {
new("UIGridLayout", { CellSize = UDim2.new(0.5, -6, 0, 30), CellPadding = UDim2.fromOffset(12, 4), SortOrder = Enum.SortOrder.LayoutOrder }),
})
local chanceLabels = {}
for i, r in Config.RARITIES do
local cell = new("Frame", { BackgroundTransparency = 1, LayoutOrder = i, ZIndex = 3, Parent = chancesBox })
new("Frame", { AnchorPoint = Vector2.new(0, 0.5), Position = UDim2.new(0, 0, 0.5, 0), Size = UDim2.fromOffset(14, 14), BackgroundColor3 = r.Color, ZIndex = 4, Parent = cell }, { corner(7) })
chanceLabels[i] = ArtUI.label({ Position = UDim2.fromOffset(22, 0), Size = UDim2.new(1, -22, 1, 0), Text = "", TextScaled = true, TextColor3 = r.Color, ZIndex = 4, Parent = cell }, 1.5)
new("UITextSizeConstraint", { MaxTextSize = 22, Parent = chanceLabels[i] })
end
ArtUI.label({ Position = UDim2.fromOffset(582, 826), Size = UDim2.fromOffset(430, 30), Text = "Гарант (защита от неудачи)", TextSize = 24, TextColor3 = SOFTG, ZIndex = 3, Parent = panel }, 1.5)
local pityLabels = {}
for i, pc in Config.PITY do
local r = Config.RarityById[pc.Rarity]
pityLabels[i] = ArtUI.label({ Position = UDim2.fromOffset(586, 830 + i * 28), Size = UDim2.fromOffset(426, 26), Text = "", TextScaled = true, TextColor3 = r.Color, ZIndex = 3, Parent = panel }, 1.5)
new("UITextSizeConstraint", { MaxTextSize = 21, Parent = pityLabels[i] })
end
-- drop pool: the 6 baked rows on the right
local poolRows = {}
for i, toy in Config.TOYS do
local row = new("Frame", { Position = UDim2.fromOffset(1048, 299 + (i - 1) * 104), Size = UDim2.fromOffset(439, 86), BackgroundTransparency = 1, ZIndex = 3, Parent = panel }, { corner(20) })
local st = new("UIStroke", { Color = GOLD, Thickness = 0, ApplyStrokeMode = Enum.ApplyStrokeMode.Border, Parent = row })
local mini = miniPattern(toy.Mask, ICE, 58, row)
mini.Position = UDim2.fromOffset(22, 14)
mini.ZIndex = 4
ArtUI.label({ Position = UDim2.fromOffset(104, 6), Size = UDim2.fromOffset(220, 38), Text = toy.Name, TextSize = 30, ZIndex = 4, Parent = row })
local sub = ArtUI.label({ Position = UDim2.fromOffset(105, 46), Size = UDim2.fromOffset(200, 30), Text = "", TextScaled = true, TextColor3 = SOFTG, ZIndex = 4, Parent = row }, 1.5)
new("UITextSizeConstraint", { MaxTextSize = 21, Parent = sub })
ArtUI.label({ Position = UDim2.fromOffset(300, 48), Size = UDim2.fromOffset(120, 28), Text = "ценность x" .. toy.Mult, TextSize = 19, TextColor3 = COIN, TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 4, Parent = row }, 1.5)
local pct = ArtUI.label({ AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -18, 0, 4), Size = UDim2.fromOffset(110, 42), Text = "", TextSize = 32, TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 4, Parent = row })
local dim = new("Frame", { Size = UDim2.fromScale(1, 1), BackgroundColor3 = Color3.new(0, 0, 0), BackgroundTransparency = 0.5, Visible = false, ZIndex = 5, Parent = row }, { corner(20) })
poolRows[i] = { row = row, stroke = st, sub = sub, pct = pct, toy = toy, mini = mini, dim = dim }
end
local function getSlots()
local s = player:GetAttribute("CraftSlots")
if typeof(s) ~= "string" or #s ~= Config.SLOT_COUNT then s = string.rep("0", Config.SLOT_COUNT) end
return s
end
local function refreshCraft()
local shards, level = attr("Shards", 0), attr("Level", 1)
local s = getSlots()
local placed = 0
for i = 1, Config.SLOT_COUNT do
local on = s:sub(i, i) == "1"
if on then placed += 1 end
local sl = slots[i]
sl.icon.Visible = on
sl.stroke.Thickness = on and 5 or 0
end
inGridLabel.Text = placed .. " / " .. shards
inGridLabel.TextColor3 = (placed > 0 and placed < Config.MIN_SHARDS) and WARN or MUTED
local booster = player:GetAttribute("CraftBooster")
local b = booster and Config.BOOSTERS[booster]
if b then
boosterStroke.Color = b.Color
boosterStroke.Thickness = 6
boosterSlotText.Text = b.Name
boosterSlotText.TextSize = 32
boosterSlotText.TextColor3 = WHITE
boosterInfo.Text = "Умножает удачу в " .. b.Luck .. " раза. Нажми на слот, чтобы убрать."
else
boosterStroke.Thickness = 0
boosterSlotText.Text = "+"
boosterSlotText.TextSize = 70
boosterSlotText.TextColor3 = MUTED
boosterInfo.Text = "Выбери бустер ниже. Он потратится при создании игрушки. Лучше всего — на 16 осколков."
end
for id, row in boosterRows do
local n = attr("Booster_" .. id, 0)
row.count.Text = "x" .. n
row.stroke.Thickness = (id == booster) and 5 or 0
end
local canGenerate = placed >= Config.MIN_SHARDS and placed <= shards
generateBtn.Active, generateBtn.AutoButtonColor = canGenerate, canGenerate
local luck = Config.Luck(placed, booster, attr("Upg_Luck", 0))
if placed == 0 then
luckLabel.Text = "Put shards in the grid"
elseif luck == 0 then
luckLabel.Text = "Need " .. (Config.MIN_SHARDS - placed) .. " осколков (минимум " .. Config.MIN_SHARDS .. ")"
else
luckLabel.Text = string.format("Удача: x%.2f", luck)
end
local chances = Config.Chances(luck > 0 and luck or 1)
for i, r in Config.RARITIES do
chanceLabels[i].Text = r.Name .. " " .. fmtPct(chances[i])
end
for i, pc in Config.PITY do
local left = pc.Rolls - attr("Pity_" .. pc.Rarity, 0)
pityLabels[i].Text = Config.RarityById[pc.Rarity].Name .. " или лучше — максимум через " .. math.max(1, left)
end
local toyChances, best, sim, bonus = Config.ToyChances(s, level)
for i, pr in poolRows do
local locked = pr.toy.Unlock > level
local isBest = (not locked) and i == best and bonus > 0
pr.dim.Visible = locked
pr.mini.Visible = true
if locked then
pr.pct.Text = "Lvl " .. pr.toy.Unlock
pr.pct.TextColor3 = MUTED
pr.sub.Text = "с уровня " .. pr.toy.Unlock
pr.sub.TextColor3 = MUTED
else
pr.pct.Text = fmtPct(toyChances[i])
pr.pct.TextColor3 = isBest and OK or WHITE
if isBest then
pr.sub.Text = (sim >= 0.999 and "точно" or string.format("pattern %d%%", math.floor(sim * 100 + 0.5))) .. string.format(" +%.1f%%", bonus)
pr.sub.TextColor3 = OK
else
pr.sub.Text = pr.toy.Count .. " shards"
pr.sub.TextColor3 = MUTED
end
end
pr.stroke.Thickness = isBest and 5 or 0
end
end
local watched = { "Shards", "Level", "CraftSlots", "CraftBooster", "Upg_Luck" }
for id in Config.BOOSTERS do table.insert(watched, "Booster_" .. id) end
for _, pc in Config.PITY do table.insert(watched, "Pity_" .. pc.Rarity) end
for _, name in watched do player:GetAttributeChangedSignal(name):Connect(refreshCraft) end
refreshCraft()
---------------------------------------------------------------- shredder menu
local SW, SH = 800, 640
local shred = makeWindow("RecycleMenu", "Шредер: переработка в осколки", SW, SH, GREEN)
local sPanel = shred.panel
-- art: shredder_bg (template pixels): toys area on the left; "Выбрано" / "Получишь" fields, info box, 4 buttons
ArtUI.artify(shred, ArtUI.IMG.shredder, 1536, 1024, { 1403, 40, 107, 87 })
local SOFTS = Color3.fromRGB(215, 230, 220)
local invCountLabel = ArtUI.label({ Position = UDim2.fromOffset(770, 222), Size = UDim2.fromOffset(104, 38), Text = "", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 4, Parent = sPanel })
local invScroll = new("ScrollingFrame", {
Position = UDim2.fromOffset(54, 306), Size = UDim2.fromOffset(926, 624), BackgroundTransparency = 1, BorderSizePixel = 0, ZIndex = 3,
ScrollBarThickness = 10, ScrollBarImageColor3 = GOLD, AutomaticCanvasSize = Enum.AutomaticSize.Y, CanvasSize = UDim2.new(), Parent = sPanel,
}, {
new("UIPadding", { PaddingTop = UDim.new(0, 8), PaddingLeft = UDim.new(0, 8), PaddingRight = UDim.new(0, 18), PaddingBottom = UDim.new(0, 8) }),
new("UIGridLayout", { CellSize = UDim2.fromOffset(168, 212), CellPadding = UDim2.fromOffset(12, 12), SortOrder = Enum.SortOrder.LayoutOrder }),
})
local emptyLabel = ArtUI.label({
Position = UDim2.fromOffset(54, 306), Size = UDim2.fromOffset(926, 624), TextWrapped = true, ZIndex = 3,
Text = "Пока нет игрушек.\nСоздай их в генераторе, а лишние приноси сюда.", TextSize = 34,
TextColor3 = SOFTS, TextXAlignment = Enum.TextXAlignment.Center, Parent = sPanel,
}, 1.5)
local selCountLabel = ArtUI.label({ Position = UDim2.fromOffset(1060, 268), Size = UDim2.fromOffset(402, 52), Text = "0", TextSize = 38, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 3, Parent = sPanel })
local recShardsLabel = ArtUI.label({ Position = UDim2.fromOffset(1140, 410), Size = UDim2.fromOffset(330, 60), Text = "+0", TextSize = 44, TextColor3 = ICE, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 3, Parent = sPanel })
-- info box
local batchLabel = ArtUI.label({ Position = UDim2.fromOffset(1046, 640), Size = UDim2.fromOffset(440, 30), Text = "", TextScaled = true, TextColor3 = OK, ZIndex = 3, Parent = sPanel }, 1.5)
ArtUI.label({ Position = UDim2.fromOffset(1046, 536), Size = UDim2.fromOffset(440, 30), Text = "Осколков за игрушку (до множителя вида):", TextScaled = true, TextColor3 = SOFTS, ZIndex = 3, Parent = sPanel }, 1.5)
local valueBox = new("Frame", { Position = UDim2.fromOffset(1046, 572), Size = UDim2.fromOffset(440, 84), BackgroundTransparency = 1, ZIndex = 3, Parent = sPanel }, {
new("UIGridLayout", { CellSize = UDim2.new(0.5, -6, 0, 25), CellPadding = UDim2.fromOffset(12, 3), SortOrder = Enum.SortOrder.LayoutOrder }),
})
for idx, r in Config.RARITIES do
local l = ArtUI.label({ Text = r.Name .. " " .. r.Shards, TextScaled = true, TextColor3 = r.Color, LayoutOrder = idx, ZIndex = 3, Parent = valueBox }, 1.5)
new("UITextSizeConstraint", { MaxTextSize = 21, Parent = l })
end
local riskHint = ArtUI.label({ Position = UDim2.fromOffset(1046, 500), Size = UDim2.fromOffset(440, 32), Text = "5+ одинаковых игрушек за раз: +" .. math.floor(Config.BATCH_BONUS * 100) .. "% осколков",
TextScaled = true, TextColor3 = OK, ZIndex = 3, Parent = sPanel }, 1.5)
local RISK_DEFAULT = riskHint.Text
-- buttons on the baked pills
local selAllBtn = button({ Position = UDim2.fromOffset(1044, 693), Size = UDim2.fromOffset(211, 52), Text = "Select all", TextSize = 26, ZIndex = 3, Parent = sPanel }, GREEN)
local selCommonBtn = button({ Position = UDim2.fromOffset(1267, 693), Size = UDim2.fromOffset(212, 52), Text = "Common", TextSize = 26, ZIndex = 3, Parent = sPanel }, GREEN)
local clearSelBtn = button({ Position = UDim2.fromOffset(1046, 764), Size = UDim2.fromOffset(435, 61), Text = "Deselect", TextSize = 30, ZIndex = 3, Parent = sPanel }, Color3.fromRGB(30, 130, 140))
local recycleBtn = button({ Name = "RecycleButton", Position = UDim2.fromOffset(1038, 846), Size = UDim2.fromOffset(452, 85), Text = "Переработать", TextSize = 40, ZIndex = 3, Parent = sPanel }, RED)
ArtUI.skin(selAllBtn, 28)
ArtUI.skin(selCommonBtn, 28)
ArtUI.skin(clearSelBtn, 32)
ArtUI.skin(recycleBtn, 42)
local cards, selected, confirmArmed = {}, {}, nil
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 refreshShredder()
local uids, items = selectedItems()
local shards = Config.RecycleYield(items, attr("Upg_Shredder", 0))
local risky = false
local perToy = {}
for _, it in items do
if Config.RarityById[it.Rarity].Index >= 5 or it.Variant 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 _ in cards do owned += 1 end
invCountLabel.Text = owned .. " / " .. Config.StorageCap(attr("Upg_Storage", 0))
emptyLabel.Visible = owned == 0
selCountLabel.Text = #uids .. (#uids >= Config.MAX_RECYCLE and " (максимум)" or "")
recShardsLabel.Text = "+" .. fmtNum(shards)
batchLabel.Text = #batches > 0 and ("Бонус за пачку: " .. table.concat(batches, ", ")) or ""
for uid, c in cards do
local on = selected[uid] == true
c.check.Visible = on
c.card.BackgroundColor3 = on and Color3.fromRGB(30, 100, 64) or Color3.fromRGB(12, 56, 36)
c.stroke.Thickness = on and 4 or 2
end
recycleBtn.Active = #uids > 0
recycleBtn.Text = confirmArmed == "recycle" and "Sure? Click again" or "Переработать"
riskHint.Text = risky and "В выборе есть легендарные, мифические или особые!" or RISK_DEFAULT
riskHint.TextColor3 = risky and WARN or OK
end
local function addCard(item)
local uid = item.Name
if item:GetAttribute("OnTree") then return end -- hanging on the Christmas tree = locked
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 or cards[uid] then return end
local variant = data.Variant and Config.VariantById[data.Variant]
local order = item:GetAttribute("Order") or 0
local card = new("TextButton", {
Text = "", BackgroundColor3 = Color3.fromRGB(12, 56, 36), AutoButtonColor = true, ZIndex = 3,
LayoutOrder = (#Config.RARITIES - r.Index) * 1000000 - (variant and 500000 or 0) - order, Parent = invScroll,
}, { corner(20) })
local st = stroke(variant and variant.Color or r.Color, 3)
st.Parent = card
local mini = miniPattern(toy.Mask, r.Color, 76, card)
mini.AnchorPoint = Vector2.new(0.5, 0)
mini.Position = UDim2.new(0.5, 0, 0, 14)
ArtUI.label({ Position = UDim2.fromOffset(6, 96), Size = UDim2.new(1, -12, 0, 30), Text = toy.Name, TextSize = 26, TextXAlignment = Enum.TextXAlignment.Center, Parent = card })
ArtUI.label({ Position = UDim2.fromOffset(6, 126), Size = UDim2.new(1, -12, 0, 24), Text = r.Name, TextScaled = true, TextColor3 = r.Color, TextXAlignment = Enum.TextXAlignment.Center, Parent = card }, 1.5)
if variant then
ArtUI.label({ Position = UDim2.fromOffset(6, 150), Size = UDim2.new(1, -12, 0, 22), Text = variant.Name .. " x" .. variant.Mult, TextScaled = true, TextColor3 = variant.Color, TextXAlignment = Enum.TextXAlignment.Center, Parent = card }, 1.5)
end
ArtUI.label({ Position = UDim2.fromOffset(6, 176), Size = UDim2.new(1, -12, 0, 28), Text = "+" .. fmtNum(math.floor(Config.Value(data) * Config.ShredderMult(attr("Upg_Shredder", 0)) + 0.5)) .. " shards", TextScaled = true, TextColor3 = ICE, TextXAlignment = Enum.TextXAlignment.Center, Parent = card }, 1.5)
local check = new("Frame", { AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -8, 0, 8), Size = UDim2.fromOffset(40, 40), BackgroundColor3 = GOLD, Visible = false, ZIndex = 5, Parent = card }, {
corner(20),
text({ Size = UDim2.fromScale(1, 1), Text = "✓", TextSize = 28, TextColor3 = NAVY, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 6 }),
})
card.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
toast("You can recycle up to " .. Config.MAX_RECYCLE .. " ornaments", WARN)
return
end
selected[uid] = true
end
confirmArmed = nil
refreshShredder()
end)
cards[uid] = { card = card, stroke = st, check = check, item = data, rarity = r }
end
local function removeCard(item)
local c = cards[item.Name]
if c then c.card:Destroy() end
cards[item.Name] = nil
selected[item.Name] = nil
refreshShredder()
end
local function watchInventory(inv)
local function watchTreeFlag(item)
item:GetAttributeChangedSignal("OnTree"):Connect(function()
if item:GetAttribute("OnTree") then removeCard(item) else addCard(item); refreshShredder() end
end)
end
for _, item in inv:GetChildren() do watchTreeFlag(item) end
inv.ChildAdded:Connect(watchTreeFlag)
for _, item in inv:GetChildren() do addCard(item) end
inv.ChildAdded:Connect(function(item)
task.defer(function() addCard(item); refreshShredder() end)
end)
inv.ChildRemoved:Connect(removeCard)
refreshShredder()
end
if player:FindFirstChild("OrnamentInventory") then
watchInventory(player.OrnamentInventory)
else
local conn
conn = player.ChildAdded:Connect(function(c)
if c.Name == "OrnamentInventory" then conn:Disconnect(); watchInventory(c) end
end)
end
local function selectWhere(pred)
selected = {}
local candidates = {}
for uid, c in cards do
if pred(c) then table.insert(candidates, { uid = uid, idx = c.rarity.Index + (c.item.Variant and 10 or 0) }) end
end
table.sort(candidates, function(a, b) return a.idx < b.idx end) -- cheapest first
for k = 1, math.min(#candidates, Config.MAX_RECYCLE) do selected[candidates[k].uid] = true end
confirmArmed = nil
refreshShredder()
end
selAllBtn.Activated:Connect(function() selectWhere(function() return true end) end)
selCommonBtn.Activated:Connect(function() selectWhere(function(c) return c.rarity.Id == "Common" and not c.item.Variant end) end)
clearSelBtn.Activated:Connect(function() selected = {}; confirmArmed = nil; refreshShredder() end)
local function submit(kind)
local uids, items = selectedItems()
if #uids == 0 then return end
local risky = false
for _, it in items do
if Config.RarityById[it.Rarity].Index >= 5 or it.Variant then risky = true end
end
if risky and confirmArmed ~= kind then
confirmArmed = kind
refreshShredder()
return
end
local machine = shred.machine
if machine and machine:GetAttribute("ShredderBusy") then
toast("The shredder is still working, wait a couple of seconds", WARN)
return
end
recycleRemote:FireServer(machine, uids)
closeWindow()
selected = {}
confirmArmed = nil
refreshShredder()
end
recycleBtn.Activated:Connect(function() submit("recycle") end)
---------------------------------------------------------------- workshop (phase 2): upgrades, fusion, boosters
-- Art: workshop_upgrades_bg (4 baked rows = the 4 upgrades) / workshop_boosters_bg (2 baked rows = the boosters).
-- The fusion tab uses the upgrades art with its own panel over the baked rows. Positions are template pixels.
local workshopRemote = folder:WaitForChild("Workshop")
local PURPLE = Color3.fromRGB(110, 60, 170)
local WW, WH = 780, 580
local shop = makeWindow("WorkshopMenu", "Workshop", WW, WH, PURPLE)
local wArt = ArtUI.artify(shop, ArtUI.IMG.workshop_upgrades)
local wPanel = shop.panel
local tabs, pages, currentTab = {}, {}, "Upgrades"
local TAB_LIST = { { "Upgrades", "Upgrades", 173 }, { "Fusion", "Fusion", 546 }, { "Boosters", "Boosters", 918 } }
for i, t in TAB_LIST do
tabs[t[1]] = ArtUI.pillButton({ Name = "Tab" .. t[1], Position = UDim2.fromOffset(t[3] - 6, 225), Size = UDim2.fromOffset(374, 109), ZIndex = 2, Parent = wPanel }, "green", t[2], 40)
pages[t[1]] = new("ScrollingFrame", {
Name = "Page" .. t[1], Position = UDim2.fromOffset(54, 356), Size = UDim2.fromOffset(1340, 664),
BackgroundTransparency = 1, BorderSizePixel = 0, ScrollBarThickness = 8, ZIndex = 3,
ScrollBarImageColor3 = GOLD, AutomaticCanvasSize = Enum.AutomaticSize.Y, CanvasSize = UDim2.new(), Visible = false, Parent = wPanel,
}, {
new("UIListLayout", { Padding = UDim.new(0, 16.5), SortOrder = Enum.SortOrder.LayoutOrder }),
})
end
-- fusion: own panel over the baked rows
local fusionCover = new("Frame", { Name = "FusionCover", Position = UDim2.fromOffset(40, 345), Size = UDim2.fromOffset(1368, 668),
BackgroundColor3 = ArtUI.GREENROW, Visible = false, ZIndex = 2, Parent = wPanel }, { corner(30), stroke(GOLD, 4) })
pages.Fusion.Position = UDim2.fromOffset(64, 366)
pages.Fusion.Size = UDim2.fromOffset(1324, 628)
pages.Fusion.UIListLayout.Padding = UDim.new(0, 12)
local shopShards = ArtUI.label({ Position = UDim2.fromOffset(1045, 80), Size = UDim2.fromOffset(222, 56), Text = "", TextScaled = true,
TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 3, Parent = wPanel })
new("UITextSizeConstraint", { MaxTextSize = 36, Parent = shopShards })
local function rowFrame(page, order, height)
if page == pages.Fusion then
return new("Frame", { Size = UDim2.new(1, -14, 0, height), BackgroundColor3 = Color3.fromRGB(12, 56, 36), LayoutOrder = order, ZIndex = 3, Parent = page }, { corner(24), stroke(GOLD, 3) })
end
-- upgrades / boosters: the row frame, circle and purple button are baked into the art
return new("Frame", { Size = UDim2.new(1, 0, 0, height), BackgroundTransparency = 1, LayoutOrder = order, ZIndex = 3, Parent = page })
end
local function actionButton(row)
local b = ArtUI.actionButton(row, row.Parent == pages.Fusion)
b.AnchorPoint = Vector2.new(1, 0.5)
b.Position = UDim2.new(1, -28, 0.5, 0)
b.Size = UDim2.fromOffset(292, 90)
b.ZIndex = 4
return b
end
local function setEnabled(b, on)
b.Active = on
b.AutoButtonColor = on
local grey = b:FindFirstChild("Grey")
if grey then grey.Visible = not on return end
b.BackgroundTransparency = on and 0 or 0.55
b.TextTransparency = on and 0 or 0.35
end
local function setCaption(b, s) b.Caption.Text = s end
local SOFT = Color3.fromRGB(225, 240, 230)
-- upgrades page
local function effectText(u, level)
if u.Id == "Luck" then return string.format("luck x%.2f", Config.LuckMult(level)) end
if u.Id == "Regen" then return string.format("запас %d, +1 за %.1f с", Config.RegenCap(level), Config.RegenSeconds(level)) end
if u.Id == "Shredder" then return string.format("recycling x%.2f", Config.ShredderMult(level)) end
if u.Id == "Storage" then return Config.StorageCap(level) .. " slots" end
return ""
end
local UPG_ICON = { Luck = "🍀", Regen = "⏳", Shredder = "♻️", Storage = "📦" }
local upgradeRows = {}
for _, u in Config.UPGRADES do
local row = rowFrame(pages.Upgrades, u.Order, 147)
text({ Position = UDim2.fromOffset(37, 13), Size = UDim2.fromOffset(121, 121), Text = UPG_ICON[u.Id] or "⭐", TextSize = 58, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 4, Parent = row })
ArtUI.label({ Position = UDim2.fromOffset(182, 12), Size = UDim2.fromOffset(600, 46), Text = u.Name, TextSize = 40, ZIndex = 4, Parent = row })
local lvl = ArtUI.label({ Position = UDim2.fromOffset(760, 16), Size = UDim2.fromOffset(240, 40), Text = "", TextSize = 30, TextColor3 = GOLD, TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 4, Parent = row })
ArtUI.label({ Position = UDim2.fromOffset(184, 62), Size = UDim2.fromOffset(820, 34), Text = u.Desc, TextSize = 26, TextColor3 = SOFT, ZIndex = 4, Parent = row }, 1.5)
local eff = ArtUI.label({ Position = UDim2.fromOffset(184, 100), Size = UDim2.fromOffset(820, 34), Text = "", TextSize = 26, TextColor3 = OK, ZIndex = 4, Parent = row }, 1.5)
local btn = actionButton(row)
btn.Activated:Connect(function() if btn.Active then workshopRemote:FireServer("Upgrade", u.Id) end end)
upgradeRows[u.Id] = { lvl = lvl, eff = eff, button = btn }
end
-- boosters page
local boosterCraftRows = {}
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)
for i, e in bOrder do
local row = rowFrame(pages.Boosters, i, 147)
local orb = new("Frame", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromOffset(97, 73), Size = UDim2.fromOffset(96, 96), BackgroundColor3 = e.b.Color, ZIndex = 4, Parent = row }, { corner(48) })
ArtUI.label({ Size = UDim2.fromScale(1, 1), Text = "x" .. e.b.Luck, TextSize = 40, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = orb })
ArtUI.label({ Position = UDim2.fromOffset(182, 22), Size = UDim2.fromOffset(820, 46), Text = e.b.Name, TextSize = 40, ZIndex = 4, Parent = row })
local owned = ArtUI.label({ Position = UDim2.fromOffset(184, 78), Size = UDim2.fromOffset(820, 36), Text = "", TextSize = 28, TextColor3 = SOFT, ZIndex = 4, Parent = row }, 1.5)
local btn = actionButton(row)
setCaption(btn, "Create · " .. Config.BOOSTER_COST[e.id])
btn.Activated:Connect(function() if btn.Active then workshopRemote:FireServer("CraftBooster", e.id) end end)
boosterCraftRows[e.id] = { owned = owned, button = btn }
end
ArtUI.label({ Size = UDim2.new(1, -40, 0, 110), TextWrapped = true, LayoutOrder = 99, Parent = pages.Boosters, TextSize = 28, TextColor3 = SOFT, ZIndex = 4,
Text = " Бустер умножает удачу одной генерации. Самый выгодный момент — 16 осколков с узором дорогой игрушки." }, 1.5)
-- fusion page (rebuilt from the inventory)
local fusionEmpty = ArtUI.label({ Size = UDim2.new(1, -30, 0, 96), TextWrapped = true, LayoutOrder = 0, Parent = pages.Fusion, TextSize = 28, TextColor3 = SOFT, ZIndex = 4,
Text = "Fusion: " .. Config.FUSION_COUNT .. " одинаковых игрушек (вид + редкость, без особых вариантов) + осколки = 1 такая же игрушка на редкость выше." }, 1.5)
local fusionRows = {}
local function rebuildFusion()
for _, r in fusionRows do r:Destroy() end
fusionRows = {}
local groups = {}
for _, c in cards do
local it = c.item
if not it.Variant and Config.RARITIES[c.rarity.Index + 1] then
local key = it.Toy .. "|" .. it.Rarity
groups[key] = groups[key] or { toy = Config.ToyById[it.Toy], rarity = c.rarity, n = 0 }
groups[key].n += 1
end
end
local list = {}
for _, g in groups do table.insert(list, g) end
table.sort(list, function(x, y)
if (x.n >= Config.FUSION_COUNT) ~= (y.n >= Config.FUSION_COUNT) then return x.n >= Config.FUSION_COUNT end
if x.rarity.Index ~= y.rarity.Index then return x.rarity.Index > y.rarity.Index end
return x.n > y.n
end)
local shards = attr("Shards", 0)
for i, g in list do
local nextR = Config.RARITIES[g.rarity.Index + 1]
local cost = Config.FUSION_COST[g.rarity.Id]
local row = rowFrame(pages.Fusion, i, 122)
local mini = miniPattern(g.toy.Mask, g.rarity.Color, 84, row)
mini.Position = UDim2.fromOffset(22, 19)
mini.ZIndex = 4
ArtUI.label({ Position = UDim2.fromOffset(132, 16), Size = UDim2.fromOffset(820, 44), Text = g.toy.Name .. " · " .. g.rarity.Name, TextSize = 36, TextColor3 = g.rarity.Color, ZIndex = 4, Parent = row })
ArtUI.label({ Position = UDim2.fromOffset(134, 66), Size = UDim2.fromOffset(820, 36), Text = "have " .. g.n .. " / " .. Config.FUSION_COUNT .. " → " .. g.toy.Name .. " · " .. nextR.Name,
TextSize = 26, TextColor3 = g.n >= Config.FUSION_COUNT and OK or SOFT, ZIndex = 4, Parent = row }, 1.5)
local btn = actionButton(row)
setCaption(btn, "Слить · " .. cost .. " shards")
setEnabled(btn, g.n >= Config.FUSION_COUNT and shards >= cost)
btn.Activated:Connect(function() if btn.Active then workshopRemote:FireServer("Fuse", g.toy.Id, g.rarity.Id) end end)
table.insert(fusionRows, row)
end
fusionEmpty.Visible = true
end
local function refreshWorkshop()
local shards = attr("Shards", 0)
shopShards.Text = fmtNum(shards) .. " shards"
for _, u in Config.UPGRADES do
local r = upgradeRows[u.Id]
local level = attr("Upg_" .. u.Id, 0)
local cost = Config.UpgradeCost(u.Id, level)
r.lvl.Text = "Lvl " .. level .. " / " .. u.Max
if cost then
r.eff.Text = effectText(u, level) .. " → " .. effectText(u, level + 1)
setCaption(r.button, "Улучшить · " .. fmtNum(cost))
setEnabled(r.button, shards >= cost)
else
r.eff.Text = effectText(u, level) .. " (максимум)"
setCaption(r.button, "Maxed")
setEnabled(r.button, false)
end
end
for id, r in boosterCraftRows do
r.owned.Text = "есть: " .. attr("Booster_" .. id, 0) .. " · удача x" .. Config.BOOSTERS[id].Luck
setEnabled(r.button, shards >= Config.BOOSTER_COST[id])
end
if currentTab == "Fusion" then rebuildFusion() end
end
local function showTab(id)
currentTab = id
for tid, b in tabs do
ArtUI.setPill(b, tid == id and "purple" or "green")
pages[tid].Visible = tid == id
end
wArt.Image = id == "Boosters" and ArtUI.IMG.workshop_boosters or ArtUI.IMG.workshop_upgrades
fusionCover.Visible = id == "Fusion"
refreshWorkshop()
end
for id, b in tabs do b.Activated:Connect(function() showTab(id) end) end
local shopWatched = { "Shards" }
for _, u in Config.UPGRADES do table.insert(shopWatched, "Upg_" .. u.Id) end
for id in Config.BOOSTERS do table.insert(shopWatched, "Booster_" .. id) end
for _, name in shopWatched do
player:GetAttributeChangedSignal(name):Connect(function() if shop.overlay.Visible then refreshWorkshop() end end)
end
task.spawn(function()
local inv = player:WaitForChild("OrnamentInventory")
local function changed() if shop.overlay.Visible and currentTab == "Fusion" then task.defer(rebuildFusion) end end
inv.ChildAdded:Connect(changed)
inv.ChildRemoved:Connect(changed)
end)
-- HUD button (works anywhere, not only at the machine)
local shopBtn = button({ Name = "WorkshopButton", Size = UDim2.fromOffset(210, 40), Text = "Workshop", TextSize = 17, LayoutOrder = 3, Parent = hudStack }, PURPLE)
shopBtn.Activated:Connect(function()
if shop.overlay.Visible then closeWindow() return end
openWindow(shop, nil, function() showTab(currentTab) end)
end)
---------------------------------------------------------------- trading (phase 3)
local tradeRemote = folder:WaitForChild("Trade")
local TR = Config.TRADE
local TEAL = Color3.fromRGB(30, 130, 140)
-- small toy tile used in the trade window
local function toyTile(parent, item, size, order)
local toy, r = Config.ToyById[item.Toy], Config.RarityById[item.Rarity]
local variant = item.Variant and Config.VariantById[item.Variant]
local tile = new("TextButton", { Text = "", Size = UDim2.fromOffset(size, size), BackgroundColor3 = SLOT, AutoButtonColor = true, LayoutOrder = order or 0, Parent = parent }, { corner(10) })
local st = stroke(variant and variant.Color or r.Color, 2)
st.Parent = tile
local mini = miniPattern(toy.Mask, r.Color, math.floor(size * 0.42), tile)
mini.AnchorPoint = Vector2.new(0.5, 0)
mini.Position = UDim2.new(0.5, 0, 0, 6)
text({ Position = UDim2.new(0, 2, 0.48, 0), Size = UDim2.new(1, -4, 0.2, 0), Text = toy.Name, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, Parent = tile })
text({ Position = UDim2.new(0, 2, 0.68, 0), Size = UDim2.new(1, -4, 0.15, 0), Text = r.Name .. (variant and (" · " .. variant.Name) or ""), TextScaled = true, Font = REGULAR, TextColor3 = variant and variant.Color or r.Color, TextXAlignment = Enum.TextXAlignment.Center, Parent = tile })
text({ Position = UDim2.new(0, 2, 0.84, 0), Size = UDim2.new(1, -4, 0.13, 0), Text = Config.Value(item) .. " shards", TextScaled = true, TextColor3 = ICE, TextXAlignment = Enum.TextXAlignment.Center, Parent = tile })
return tile, st
end
-- 1) player picker
local picker = makeWindow("TradePicker", "Обмен: выбери игрока", 540, 470, TEAL)
-- art: trade_bg (template pixels): the strip on top = hint, the big panel = player list
ArtUI.artify(picker, ArtUI.IMG.trade)
local pickList = new("ScrollingFrame", {
Position = UDim2.fromOffset(60, 335), Size = UDim2.fromOffset(1330, 630), BackgroundTransparency = 1, ZIndex = 3,
BorderSizePixel = 0, ScrollBarThickness = 10, ScrollBarImageColor3 = GOLD, AutomaticCanvasSize = Enum.AutomaticSize.Y, CanvasSize = UDim2.new(), Parent = picker.panel,
}, {
new("UIPadding", { PaddingTop = UDim.new(0, 6), PaddingLeft = UDim.new(0, 6), PaddingRight = UDim.new(0, 18), PaddingBottom = UDim.new(0, 6) }),
new("UIListLayout", { Padding = UDim.new(0, 12), SortOrder = Enum.SortOrder.LayoutOrder }),
})
local pickHint = ArtUI.label({ Position = UDim2.fromOffset(140, 232), Size = UDim2.fromOffset(1170, 58), TextWrapped = true, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 3, Parent = picker.panel,
Text = "Trading unlocks at level " .. TR.MIN_LEVEL .. "-го уровня у обоих. Можно передать до " .. TR.MAX_ITEMS .. " ornaments and shards (tax " .. math.floor(TR.TAX * 100) .. "%). Новые игрушки можно обменять через " .. (TR.MIN_AGE // 60) .. " min after they are made." })
local function rebuildPicker()
for _, c in pickList:GetChildren() do if c:IsA("Frame") or c:IsA("TextLabel") then c:Destroy() end end
local n = 0
for _, p in Players:GetPlayers() do
if p ~= player then
n += 1
local lvl = p:GetAttribute("Level") or 1
local row = new("Frame", { Size = UDim2.new(1, 0, 0, 104), BackgroundColor3 = Color3.fromRGB(12, 56, 36), LayoutOrder = n, ZIndex = 3, Parent = pickList }, { corner(22), stroke(GOLD, 3) })
ArtUI.label({ Position = UDim2.fromOffset(28, 14), Size = UDim2.new(1, -420, 0, 42), Text = p.DisplayName, TextSize = 36, Parent = row })
ArtUI.label({ Position = UDim2.fromOffset(30, 58), Size = UDim2.new(1, -420, 0, 32), Text = "уровень " .. lvl, TextSize = 26, TextColor3 = lvl >= TR.MIN_LEVEL and OK or Color3.fromRGB(205, 220, 210), Parent = row }, 1.5)
local b = button({ AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -22, 0.5, 0), Size = UDim2.fromOffset(330, 70), Text = "Offer a trade", TextSize = 28, Parent = row }, GREEN)
ArtUI.skin(b)
b.Activated:Connect(function()
tradeRemote:FireServer("Request", p)
closeWindow()
end)
end
end
if n == 0 then
ArtUI.label({ Size = UDim2.new(1, 0, 0, 300), Text = "Nobody else is on this server", TextSize = 34, TextColor3 = Color3.fromRGB(215, 230, 220), TextXAlignment = Enum.TextXAlignment.Center, Parent = pickList })
end
end
-- 2) incoming request popup (not modal)
local popup = new("Frame", {
Name = "TradeRequest", AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 16), Size = UDim2.fromOffset(440, 118),
BackgroundColor3 = NAVY, Visible = false, ZIndex = 20, Parent = gui,
}, { corner(14), stroke(TEAL, 3) })
local popupText = text({ Position = UDim2.fromOffset(16, 10), Size = UDim2.new(1, -32, 0, 44), TextWrapped = true, Text = "", TextSize = 17, ZIndex = 21, Parent = popup })
local popupBar = new("Frame", { Position = UDim2.fromOffset(16, 58), Size = UDim2.new(1, -32, 0, 4), BackgroundColor3 = TEAL, BorderSizePixel = 0, ZIndex = 21, Parent = popup })
local acceptBtn = button({ Position = UDim2.fromOffset(16, 70), Size = UDim2.fromOffset(196, 38), Text = "Accept", TextSize = 16, ZIndex = 21, Parent = popup }, GREEN)
local declineBtn = button({ Position = UDim2.fromOffset(228, 70), Size = UDim2.fromOffset(196, 38), Text = "Decline", TextSize = 16, ZIndex = 21, Parent = popup }, RED)
local pendingFrom
acceptBtn.Activated:Connect(function() if pendingFrom then tradeRemote:FireServer("Respond", pendingFrom, true) end popup.Visible = false; pendingFrom = nil end)
declineBtn.Activated:Connect(function() if pendingFrom then tradeRemote:FireServer("Respond", pendingFrom, false) end popup.Visible = false; pendingFrom = nil end)
-- 3) trade window
local TW, TH = 960, 640
local trade = makeWindow("TradeMenu", "Trade", TW, TH, TEAL)
local tPanel = trade.panel
-- art: trade_bg (template pixels). Left half = my side, right half = theirs; the strip on top = rules.
ArtUI.artify(trade, ArtUI.IMG.trade)
local COLW = 640
local LX, RX = 70, 745 -- left / right column x
local SOFT2 = Color3.fromRGB(215, 230, 220)
local myTitle = ArtUI.label({ Position = UDim2.fromOffset(LX, 340), Size = UDim2.fromOffset(COLW, 42), Text = "Твоё предложение", TextSize = 32, ZIndex = 3, Parent = tPanel })
local myValue = ArtUI.label({ Position = UDim2.fromOffset(LX, 344), Size = UDim2.fromOffset(COLW, 36), Text = "", TextSize = 24, TextColor3 = ICE, TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 3, Parent = tPanel }, 1.5)
local theirTitle = ArtUI.label({ Position = UDim2.fromOffset(RX, 340), Size = UDim2.fromOffset(COLW, 42), Text = "Предложение", TextSize = 32, ZIndex = 3, Parent = tPanel })
local theirValue = ArtUI.label({ Position = UDim2.fromOffset(RX, 344), Size = UDim2.fromOffset(COLW, 36), Text = "", TextSize = 24, TextColor3 = ICE, TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 3, Parent = tPanel }, 1.5)
local function offerGrid(x)
return new("Frame", { Position = UDim2.fromOffset(x, 388), Size = UDim2.fromOffset(COLW, 318), BackgroundColor3 = Color3.fromRGB(10, 48, 30), ZIndex = 3, Parent = tPanel }, {
corner(22), stroke(GOLD, 3),
new("UIPadding", { PaddingTop = UDim.new(0, 10), PaddingLeft = UDim.new(0, 10) }),
new("UIGridLayout", { CellSize = UDim2.fromOffset(146, 144), CellPadding = UDim2.fromOffset(10, 10), SortOrder = Enum.SortOrder.LayoutOrder }),
})
end
local myGrid, theirGrid = offerGrid(LX), offerGrid(RX)
local myStatus = ArtUI.label({ Position = UDim2.fromOffset(LX, 712), Size = UDim2.fromOffset(COLW, 34), Text = "", TextSize = 26, ZIndex = 3, Parent = tPanel }, 1.5)
local theirStatus = ArtUI.label({ Position = UDim2.fromOffset(RX, 712), Size = UDim2.fromOffset(COLW, 34), Text = "", TextSize = 26, ZIndex = 3, Parent = tPanel }, 1.5)
-- my shards
ArtUI.label({ Position = UDim2.fromOffset(LX, 752), Size = UDim2.fromOffset(150, 52), Text = "Осколки:", TextSize = 28, ZIndex = 3, Parent = tPanel })
local shardBox = new("TextBox", {
Position = UDim2.fromOffset(LX + 150, 752), Size = UDim2.fromOffset(170, 52), BackgroundColor3 = Color3.fromRGB(16, 70, 44), Text = "0", PlaceholderText = "0",
ClearTextOnFocus = false, Font = BOLD, TextSize = 28, TextColor3 = WHITE, ZIndex = 3, Parent = tPanel,
}, { corner(12), stroke(GOLD, 2) })
local shardSet = button({ Position = UDim2.fromOffset(LX + 332, 752), Size = UDim2.fromOffset(140, 52), Text = "Set", TextSize = 26, ZIndex = 3, Parent = tPanel }, TEAL)
ArtUI.skin(shardSet, 28)
local myShardNote = ArtUI.label({ Position = UDim2.fromOffset(LX + 484, 752), Size = UDim2.fromOffset(156, 52), Text = "", TextScaled = true, TextColor3 = SOFT2, TextWrapped = true, ZIndex = 3, Parent = tPanel }, 1.5)
local function sendShards() tradeRemote:FireServer("SetShards", tonumber(shardBox.Text) or 0) end
shardSet.Activated:Connect(sendShards)
shardBox.FocusLost:Connect(function(enter) if enter then sendShards() end end)
local theirShards = ArtUI.label({ Position = UDim2.fromOffset(RX, 752), Size = UDim2.fromOffset(COLW, 52), Text = "", TextScaled = true, TextColor3 = ICE, ZIndex = 3, Parent = tPanel }, 1.5)
-- my inventory (click to add)
ArtUI.label({ Position = UDim2.fromOffset(LX, 812), Size = UDim2.fromOffset(COLW, 30), Text = "Твои игрушки (нажми, чтобы добавить)", TextSize = 24, TextColor3 = SOFT2, ZIndex = 3, Parent = tPanel }, 1.5)
local invList = new("ScrollingFrame", {
Position = UDim2.fromOffset(LX, 846), Size = UDim2.fromOffset(COLW, 124), BackgroundColor3 = Color3.fromRGB(10, 48, 30), ZIndex = 3,
BorderSizePixel = 0, ScrollBarThickness = 8, ScrollBarImageColor3 = GOLD, AutomaticCanvasSize = Enum.AutomaticSize.Y, CanvasSize = UDim2.new(), Parent = tPanel,
}, {
corner(18), stroke(GOLD, 2),
new("UIPadding", { PaddingTop = UDim.new(0, 8), PaddingLeft = UDim.new(0, 8), PaddingRight = UDim.new(0, 14), PaddingBottom = UDim.new(0, 8) }),
new("UIGridLayout", { CellSize = UDim2.fromOffset(104, 104), CellPadding = UDim2.fromOffset(8, 8), SortOrder = Enum.SortOrder.LayoutOrder }),
})
-- the strip on top: rules; right side: warnings + countdown
local rules = ArtUI.label({ Position = UDim2.fromOffset(140, 232), Size = UDim2.fromOffset(1170, 58), TextWrapped = true, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 3, Parent = tPanel,
Text = "1. Положите игрушки и осколки. 2. Оба нажимают “Готов”. 3. Через " .. TR.COUNTDOWN .. " с оба нажимают “Подтвердить”. Любое изменение снимает готовность. Налог " .. math.floor(TR.TAX * 100) .. "% с переданных осколков." }, 1.5)
local warnLabel = ArtUI.label({ Position = UDim2.fromOffset(RX, 812), Size = UDim2.fromOffset(COLW, 40), TextWrapped = true, TextScaled = true, Text = "", TextColor3 = WARN, ZIndex = 3, Parent = tPanel }, 1.5)
local countdownLabel = ArtUI.label({ Position = UDim2.fromOffset(RX, 852), Size = UDim2.fromOffset(COLW, 36), Text = "", TextSize = 30, TextColor3 = GOLD, ZIndex = 3, Parent = tPanel })
local readyBtn = button({ Name = "Ready", Position = UDim2.fromOffset(RX, 896), Size = UDim2.fromOffset(204, 70), Text = "Ready", TextSize = 28, ZIndex = 3, Parent = tPanel }, Color3.fromRGB(70, 82, 120))
local confirmBtn = button({ Name = "Confirm", Position = UDim2.fromOffset(RX + 218, 896), Size = UDim2.fromOffset(204, 70), Text = "Confirm", TextSize = 26, ZIndex = 3, Parent = tPanel }, GREEN)
local cancelBtn = button({ Name = "CancelTrade", Position = UDim2.fromOffset(RX + 436, 896), Size = UDim2.fromOffset(204, 70), Text = "Cancel", TextSize = 26, ZIndex = 3, Parent = tPanel }, RED)
for _, b in { readyBtn, confirmBtn, cancelBtn } do ArtUI.skin(b) end
local state, lastTheirs = nil, {}
readyBtn.Activated:Connect(function() if state then tradeRemote:FireServer("Ready", not state.me.ready) end end)
confirmBtn.Activated:Connect(function() if state and state.canConfirm then tradeRemote:FireServer("Confirm") end end)
cancelBtn.Activated:Connect(function() tradeRemote:FireServer("Cancel") end)
-- closing the window with X also cancels the trade
for _, n in { "Close", "ArtClose" } do
local c = trade.panel:FindFirstChild(n, true)
if c then c.Activated:Connect(function() if state then tradeRemote:FireServer("Cancel") end end) end
end
local function clearChildren(f) for _, c in f:GetChildren() do if c:IsA("GuiButton") or c:IsA("Frame") then c:Destroy() end end end
local function renderTrade()
if not state then return end
local me, them = state.me, state.them
theirTitle.Text = "Предложение: " .. them.name
myValue.Text = "value " .. fmtNum(me.value) .. " shards"
theirValue.Text = "value " .. fmtNum(them.value) .. " shards"
-- my offer (click removes)
clearChildren(myGrid)
local inOffer = {}
for k, it in me.items do
inOffer[it.uid] = true
local tile = toyTile(myGrid, it, 146, k)
tile.Activated:Connect(function() tradeRemote:FireServer("RemoveItem", it.uid) end)
end
-- their offer (new items flash)
clearChildren(theirGrid)
local nowTheirs = {}
for k, it in them.items do
nowTheirs[it.uid] = true
local tile, st = toyTile(theirGrid, it, 146, k)
tile.AutoButtonColor = false
if not lastTheirs[it.uid] then
st.Color, st.Thickness = GOLD, 4
text({ AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -4, 0, 2), Size = UDim2.fromOffset(80, 24), Text = "NEW", TextSize = 20, TextColor3 = GOLD, TextXAlignment = Enum.TextXAlignment.Right, Parent = tile })
end
end
lastTheirs = nowTheirs
myStatus.Text = (me.confirmed and "✓ подтвердил") or (me.ready and "✓ готов") or "not ready"
myStatus.TextColor3 = me.ready and OK or MUTED
theirStatus.Text = them.name .. ": " .. ((them.confirmed and "confirmed") or (them.ready and "ready") or "not ready")
theirStatus.TextColor3 = them.ready and OK or MUTED
if not shardBox:IsFocused() then shardBox.Text = tostring(me.shards) end
myShardNote.Text = me.shards > 0 and ("arrives: " .. math.floor(me.shards * (1 - TR.TAX))) or ""
theirShards.Text = them.shards > 0 and ("+" .. fmtNum(math.floor(them.shards * (1 - TR.TAX))) .. " shards to you (after tax)") or "осколков нет"
-- my inventory
clearChildren(invList)
local inv = player:FindFirstChild("OrnamentInventory")
if inv then
local list = {}
for _, c in inv:GetChildren() do
if not inOffer[c.Name] and not c:GetAttribute("OnTree") then table.insert(list, c) end
end
table.sort(list, function(x, y)
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)
for k, c in list do
local it = { Toy = c:GetAttribute("Toy"), Rarity = c:GetAttribute("Rarity"), Variant = c:GetAttribute("Variant") }
local tile = toyTile(invList, it, 104, k)
local age = os.time() - (c:GetAttribute("Created") or 0)
if age < TR.MIN_AGE then
tile.BackgroundTransparency = 0.6
text({ Size = UDim2.fromScale(1, 1), BackgroundTransparency = 0, BackgroundColor3 = Color3.new(0, 0, 0), Text = "через " .. math.ceil((TR.MIN_AGE - age) / 60) .. " min", TextSize = 12, TextXAlignment = Enum.TextXAlignment.Center, Parent = tile }).BackgroundTransparency = 0.45
else
tile.Activated:Connect(function() tradeRemote:FireServer("AddItem", c.Name) end)
end
end
end
-- warnings + buttons
local hi, lo = math.max(me.value, them.value), math.min(me.value, them.value)
if (me.value > 0 or them.value > 0) and (lo == 0 or hi / lo > TR.WARN_RATIO) then
warnLabel.Text = me.value > them.value and "Warning: you're giving much more than you get!" or "You're getting much more — make sure it's fair."
else
warnLabel.Text = ""
end
readyBtn.Text = me.ready and "Not ready" or "Ready"
readyBtn.BackgroundColor3 = me.ready and GOLD:Lerp(SLOT, 0.4) or Color3.fromRGB(70, 82, 120)
confirmBtn.Active = state.canConfirm and not me.confirmed
confirmBtn.BackgroundTransparency = confirmBtn.Active and 0 or 0.55
confirmBtn.Text = me.confirmed and "Ждём второго..." or "Confirm"
if state.countdown and state.countdown > 0 then
countdownLabel.Text = "Confirm in " .. math.ceil(state.countdown) .. "s"
elseif state.canConfirm then
countdownLabel.Text = "Можно подтверждать!"
else
countdownLabel.Text = (me.ready and them.ready) and "" or "Ждём, пока оба нажмут “Готов”"
end
end
-- local countdown tick (the server re-sends the state when the countdown ends)
task.spawn(function()
while true do
task.wait(0.25)
if state and state.countdown and state.countdown > 0 and trade.overlay.Visible then
state.countdown = math.max(0, state.countdown - 0.25)
countdownLabel.Text = "Confirm in " .. math.ceil(state.countdown) .. "s"
end
end
end)
tradeRemote.OnClientEvent:Connect(function(kind, data)
if kind == "Incoming" then
pendingFrom = data.from
popupText.Text = data.name .. " (lvl " .. data.level .. ") wants to trade"
popup.Visible = true
popupBar.Size = UDim2.new(1, -32, 0, 4)
TweenService:Create(popupBar, TweenInfo.new(data.ttl, Enum.EasingStyle.Linear), { Size = UDim2.new(0, 0, 0, 4) }):Play()
local mine = pendingFrom
task.delay(data.ttl, function() if pendingFrom == mine then popup.Visible = false; pendingFrom = nil end end)
elseif kind == "State" then
local first = state == nil
state = data
if first then lastTheirs = {} for _, it in data.them.items do lastTheirs[it.uid] = true end end
if not trade.overlay.Visible then openWindow(trade, nil) end
renderTrade()
elseif kind == "Closed" then
state = nil
lastTheirs = {}
if trade.overlay.Visible then closeWindow() end
if data then toast(data, WARN) end
end
end)
task.spawn(function()
local inv = player:WaitForChild("OrnamentInventory")
local function changed() if state then task.defer(renderTrade) end end
inv.ChildAdded:Connect(changed)
inv.ChildRemoved:Connect(changed)
end)
-- HUD button
local tradeBtn = button({ Name = "TradeButton", Size = UDim2.fromOffset(210, 40), Text = "Trade", TextSize = 17, LayoutOrder = 4, Parent = hudStack }, TEAL)
tradeBtn.Activated:Connect(function()
if state then openWindow(trade, nil); renderTrade() return end
if picker.overlay.Visible then closeWindow() return end
openWindow(picker, nil, rebuildPicker)
end)
do -- section scope (keeps the script under Luau's 200 local limit)
---------------------------------------------------------------- market (phase 5, all servers)
local marketFn = folder:WaitForChild("Market")
local MK = Config.MARKET
local AMBER = Color3.fromRGB(165, 100, 20)
local MW, MH = 1000, 650
local market = makeWindow("MarketMenu", "Ornament Market", MW, MH, AMBER)
local mPanel = market.panel
-- art: market_bg (template pixels). Buy tab = the baked chip rows + list; sell / mine tabs cover them with a panel.
ArtUI.artify(market, ArtUI.IMG.market)
local mTabs, mPages, mTab = {}, {}, "Buy"
for k, t in { { "Buy", "Buy", 173 }, { "Sell", "Sell", 546 }, { "Mine", "My Listings", 918 } } do
mTabs[t[1]] = ArtUI.pillButton({ Name = "Tab" .. t[1], Position = UDim2.fromOffset(t[3] - 6, 225), Size = UDim2.fromOffset(374, 109), ZIndex = 4, Parent = mPanel }, "green", t[2], 40)
mPages[t[1]] = new("Frame", { Name = "Page" .. t[1], Position = UDim2.fromOffset(40, 340), Size = UDim2.fromOffset(1368, 706), BackgroundTransparency = 1, Visible = false, ZIndex = 2, Parent = mPanel })
if t[1] ~= "Buy" then
new("Frame", { Name = "Cover", Size = UDim2.fromScale(1, 1), BackgroundColor3 = ArtUI.GREENROW, ZIndex = 2, Parent = mPages[t[1]] }, { corner(30), stroke(GOLD, 4) })
end
end
local mShards = ArtUI.label({ Position = UDim2.fromOffset(1045, 80), Size = UDim2.fromOffset(222, 56), Text = "", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 3, Parent = mPanel })
new("UITextSizeConstraint", { MaxTextSize = 36, Parent = mShards })
local mGate = ArtUI.label({ Position = UDim2.fromOffset(700, 160), Size = UDim2.fromOffset(720, 30), Text = "", TextSize = 22, TextColor3 = WARN, TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 3, Parent = mPanel }, 1.5)
local function call(action, ...)
local ok, res = pcall(marketFn.InvokeServer, marketFn, action, ...)
if not ok or type(res) ~= "table" then return { ok = false, msg = "No connection to the market" } end
return res
end
local function scrollGrid(parent, pos, size, cell)
return new("ScrollingFrame", {
Position = pos, Size = size, BackgroundTransparency = 1, BorderSizePixel = 0, ZIndex = 3,
ScrollBarThickness = 10, ScrollBarImageColor3 = GOLD, AutomaticCanvasSize = Enum.AutomaticSize.Y, CanvasSize = UDim2.new(), Parent = parent,
}, {
new("UIPadding", { PaddingTop = UDim.new(0, 8), PaddingLeft = UDim.new(0, 8), PaddingRight = UDim.new(0, 16), PaddingBottom = UDim.new(0, 8) }),
new("UIGridLayout", { CellSize = cell, CellPadding = UDim2.fromOffset(14, 14), SortOrder = Enum.SortOrder.LayoutOrder }),
})
end
local function clearList(f) for _, c in f:GetChildren() do if c:IsA("GuiObject") then c:Destroy() end end end
local function listingCard(parent, item, order)
local toy, r = Config.ToyById[item.Toy], Config.RarityById[item.Rarity]
local variant = item.Variant and Config.VariantById[item.Variant]
local card = new("Frame", { BackgroundColor3 = Color3.fromRGB(12, 56, 36), LayoutOrder = order, ZIndex = 3, Parent = parent }, { corner(18) })
stroke(variant and variant.Color or r.Color, 3).Parent = card
local mini = miniPattern(toy.Mask, r.Color, 70, card)
mini.AnchorPoint = Vector2.new(0.5, 0)
mini.Position = UDim2.new(0.5, 0, 0, 12)
ArtUI.label({ Position = UDim2.fromOffset(6, 88), Size = UDim2.new(1, -12, 0, 30), Text = toy.Name, TextSize = 26, TextXAlignment = Enum.TextXAlignment.Center, Parent = card })
ArtUI.label({ Position = UDim2.fromOffset(6, 118), Size = UDim2.new(1, -12, 0, 24), Text = r.Name .. (variant and (" · " .. variant.Name) or ""), TextScaled = true, TextColor3 = variant and variant.Color or r.Color, TextXAlignment = Enum.TextXAlignment.Center, Parent = card }, 1.5)
return card
end
-- BUY tab
local buyFilter = { toy = nil, rarity = nil, sort = "cheap" }
local buyPage = mPages.Buy
-- chips sit on the baked chip slots of the art (template x ranges; the page starts at template (40, 340))
local CHIP_X = { { 52, 252 }, { 260, 440 }, { 450, 632 }, { 640, 818 }, { 828, 1005 }, { 1012, 1187 }, { 1205, 1397 } }
local SORT_X = { { 52, 212 }, { 222, 380 }, { 392, 548 }, { 560, 718 } }
local function chipRow(y0, y1, xs, entries, onPick, colored)
local chips = {}
for k, e in entries do
local x = xs[k] or xs[#xs]
local b = new("ImageButton", { Position = UDim2.fromOffset(x[1] - 48, y0 - 348), Size = UDim2.fromOffset(x[2] - x[1] + 16, y1 - y0 + 16),
BackgroundTransparency = 1, AutoButtonColor = true, ZIndex = 3, Parent = buyPage }, { new("UICorner", { CornerRadius = UDim.new(0.5, 0) }) })
if not colored then ArtUI.setPill(b, "green") end -- colored row: the rarity colours are baked in the art
local lbl = ArtUI.label({ Position = UDim2.fromScale(0.08, 0.16), Size = UDim2.fromScale(0.84, 0.68), Text = e.label, TextScaled = true,
TextColor3 = (not colored and e.color) or WHITE, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 4, Parent = b }, 1.5)
new("UITextSizeConstraint", { MaxTextSize = 26, Parent = lbl })
local st = new("UIStroke", { Color = WHITE, Thickness = 0, ApplyStrokeMode = Enum.ApplyStrokeMode.Border, Parent = b })
chips[k] = { b = b, st = st, value = e.value, colored = colored }
b.Activated:Connect(function() onPick(e.value) end)
end
return chips
end
local toyChips, rarityChips, sortChips
local refreshBuy
local toyEntries = { { label = "All ornaments", value = false, w = 110 } }
for _, t in Config.TOYS do table.insert(toyEntries, { label = t.Name, value = t.Id, w = 108 }) end
local rarityEntries = { { label = "All rarities", value = false, w = 110 } }
for _, r in Config.RARITIES do table.insert(rarityEntries, { label = r.Name, value = r.Id, color = r.Color, w = 108 }) end
toyChips = chipRow(346, 410, CHIP_X, toyEntries, function(v) buyFilter.toy = v or nil; refreshBuy() end)
rarityChips = chipRow(422, 484, CHIP_X, rarityEntries, function(v) buyFilter.rarity = v or nil; refreshBuy() end, true)
sortChips = chipRow(500, 554, SORT_X, { { label = "Cheapest", value = "cheap" }, { label = "Priciest", value = "expensive" }, { label = "Newest", value = "new" }, { label = "Refresh", value = "refresh", color = GOLD } },
function(v) if v ~= "refresh" then buyFilter.sort = v end refreshBuy() end)
local buyCount = ArtUI.label({ Position = UDim2.fromOffset(700, 166), Size = UDim2.fromOffset(640, 40), Text = "", TextSize = 24, TextColor3 = Color3.fromRGB(215, 230, 220), TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 3, Parent = buyPage }, 1.5)
local buyList = scrollGrid(buyPage, UDim2.fromOffset(16, 245), UDim2.fromOffset(1336, 448), UDim2.fromOffset(204, 290))
local function paintChips(chips, current)
for _, c in chips do
local on = (c.value or nil) == current
if c.colored then
c.st.Thickness = on and 5 or 0 -- selected rarity: white ring
else
ArtUI.setPill(c.b, on and "gold" or "green")
end
end
end
local buyBusy = false
refreshBuy = function()
paintChips(toyChips, buyFilter.toy)
paintChips(rarityChips, buyFilter.rarity)
paintChips(sortChips, buyFilter.sort)
if buyBusy then return end
buyBusy = true
task.spawn(function()
local res = call("Browse", { toy = buyFilter.toy, rarity = buyFilter.rarity, sort = buyFilter.sort })
buyBusy = false
clearList(buyList)
local oldEmpty = buyPage:FindFirstChild("EmptyNote")
if oldEmpty then oldEmpty:Destroy() end
if not res.ok then buyCount.Text = res.msg or "" return end
buyCount.Text = "showing " .. #res.items .. " of " .. res.total .. (res.remote and "" or " (локальный рынок Studio)")
if #res.items == 0 then
-- outside the grid (a grid child would be squeezed into one card cell)
ArtUI.label({ Name = "EmptyNote", Position = UDim2.fromOffset(16, 245), Size = UDim2.fromOffset(1336, 300), ZIndex = 4, Text = "Лотов нет. Попробуй другой фильтр.", TextSize = 32, TextXAlignment = Enum.TextXAlignment.Center, TextColor3 = Color3.fromRGB(215, 230, 220), Parent = buyPage }, 1.5)
end
for k, l in res.items do
local card = listingCard(buyList, l.item, k)
ArtUI.label({ Position = UDim2.fromOffset(6, 148), Size = UDim2.new(1, -12, 0, 32), Text = fmtNum(l.price) .. " shards", TextSize = 28, TextColor3 = ICE, TextXAlignment = Enum.TextXAlignment.Center, Parent = card })
ArtUI.label({ Position = UDim2.fromOffset(6, 182), Size = UDim2.new(1, -12, 0, 24), Text = "seller: " .. tostring(l.seller), TextSize = 19, TextColor3 = Color3.fromRGB(205, 220, 210), TextTruncate = Enum.TextTruncate.AtEnd, TextXAlignment = Enum.TextXAlignment.Center, Parent = card }, 1.5)
local b = button({ Position = UDim2.new(0, 10, 1, -60), Size = UDim2.new(1, -20, 0, 50), Text = l.mine and "Your listing" or "Buy", TextSize = 24, Parent = card }, l.mine and Color3.fromRGB(70, 82, 120) or GREEN)
ArtUI.skin(b)
if l.mine then
b.Active = false; b.AutoButtonColor = false
else
b.Activated:Connect(function()
if b:GetAttribute("Armed") ~= true then
b:SetAttribute("Armed", true)
b.Text = "Sure? " .. fmtNum(l.price)
task.delay(3, function() if b.Parent then b:SetAttribute("Armed", false); b.Text = "Buy" end end)
return
end
b.Text = "..."
task.spawn(function()
local r2 = call("Buy", l.id, l.price)
toast(r2.msg or (r2.ok and "Bought" or "Failed"), r2.ok and OK or WARN)
refreshBuy()
end)
end)
end
end
end)
end
-- SELL tab
local sellPage = mPages.Sell
ArtUI.label({ Position = UDim2.fromOffset(34, 20), Size = UDim2.fromOffset(800, 40), Text = "Pick an ornament", TextSize = 32, ZIndex = 3, Parent = sellPage })
local sellList = scrollGrid(sellPage, UDim2.fromOffset(26, 66), UDim2.fromOffset(850, 616), UDim2.fromOffset(150, 150))
local sellBox = new("Frame", { Position = UDim2.fromOffset(900, 22), Size = UDim2.fromOffset(440, 662), BackgroundColor3 = Color3.fromRGB(10, 48, 30), ZIndex = 3, Parent = sellPage }, { corner(22), stroke(GOLD, 3) })
local sellTitle = ArtUI.label({ Position = UDim2.fromOffset(20, 16), Size = UDim2.new(1, -40, 0, 36), Text = "Ничего не выбрано", TextScaled = true, Parent = sellBox })
local sellInfo = ArtUI.label({ Position = UDim2.fromOffset(20, 58), Size = UDim2.new(1, -40, 0, 64), Text = "", TextWrapped = true, TextSize = 21, TextColor3 = Color3.fromRGB(215, 230, 220), TextYAlignment = Enum.TextYAlignment.Top, Parent = sellBox }, 1.5)
ArtUI.label({ Position = UDim2.fromOffset(20, 128), Size = UDim2.new(1, -40, 0, 30), Text = "Цена (осколки):", TextSize = 26, Parent = sellBox })
local priceBox = new("TextBox", { Position = UDim2.fromOffset(20, 162), Size = UDim2.new(1, -40, 0, 60), BackgroundColor3 = Color3.fromRGB(16, 70, 44), Text = "", PlaceholderText = "price", ClearTextOnFocus = false, Font = BOLD, TextSize = 32, TextColor3 = WHITE, Parent = sellBox }, { corner(14), stroke(GOLD, 2) })
local payoutLabel = ArtUI.label({ Position = UDim2.fromOffset(20, 228), Size = UDim2.new(1, -40, 0, 56), Text = "", TextWrapped = true, TextSize = 22, TextColor3 = OK, Parent = sellBox }, 1.5)
local listBtn = button({ Position = UDim2.fromOffset(20, 290), Size = UDim2.new(1, -40, 0, 70), Text = "Выставить на рынок", TextSize = 30, Parent = sellBox }, AMBER)
ArtUI.skin(listBtn, 34)
ArtUI.label({ Position = UDim2.fromOffset(20, 376), Size = UDim2.new(1, -40, 0, 270), TextWrapped = true, TextSize = 20, TextColor3 = Color3.fromRGB(205, 220, 210), TextYAlignment = Enum.TextYAlignment.Top, Parent = sellBox,
Text = "• Лот виден игрокам на всех серверах.\n• Налог " .. math.floor(MK.TAX * 100) .. "% с продажи.\n• Лот живёт " .. (MK.DURATION // 86400) .. " дня, потом игрушка возвращается.\n• Осколки за продажу придут, даже если ты не в игре.\n• Не больше " .. MK.MAX_LISTINGS .. " лотов одновременно.\n• Минимальная цена — ценность игрушки в шредере." })
local sellSelected
local function updatePayout()
local p = tonumber(priceBox.Text)
payoutLabel.Text = (sellSelected and p) and ("You get " .. fmtNum(math.floor(p * (1 - MK.TAX))) .. " осколков после налога") or ""
end
priceBox:GetPropertyChangedSignal("Text"):Connect(updatePayout)
local function refreshSell()
clearList(sellList)
local inv = player:FindFirstChild("OrnamentInventory")
if not inv then return end
local list = {}
for _, c in inv:GetChildren() do
if not c:GetAttribute("OnTree") then table.insert(list, c) end -- toys on the tree can not be sold
end
table.sort(list, function(x, y)
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)
for k, c in list do
local it = { Toy = c:GetAttribute("Toy"), Rarity = c:GetAttribute("Rarity"), Variant = c:GetAttribute("Variant") }
local tile, st = toyTile(sellList, it, 150, k)
if sellSelected and sellSelected.uid == c.Name then st.Color, st.Thickness = GOLD, 4 end
local age = os.time() - (c:GetAttribute("Created") or 0)
if age < Config.TRADE.MIN_AGE then
tile.BackgroundTransparency = 0.6
local lock = text({ Size = UDim2.fromScale(1, 1), Text = "через " .. math.ceil((Config.TRADE.MIN_AGE - age) / 60) .. " min", TextSize = 24, TextXAlignment = Enum.TextXAlignment.Center, Parent = tile })
lock.FontFace = ArtUI.FONT
lock.BackgroundTransparency = 0.45
lock.BackgroundColor3 = Color3.new(0, 0, 0)
else
tile.Activated:Connect(function()
sellSelected = { uid = c.Name, item = it }
local minP = Config.MinPrice(it)
sellTitle.Text = Config.ToyById[it.Toy].Name .. " · " .. Config.RarityById[it.Rarity].Name .. (it.Variant and (" · " .. Config.VariantById[it.Variant].Name) or "")
sellInfo.Text = "Ценность в шредере: " .. Config.Value(it) .. " осколков.\nМинимальная цена: " .. minP .. "."
priceBox.Text = tostring(minP * 2)
updatePayout()
refreshSell()
end)
end
end
end
listBtn.Activated:Connect(function()
if not sellSelected then toast("Сначала выбери игрушку", WARN) return end
local price = tonumber(priceBox.Text)
if not price then toast("Укажи цену числом", WARN) return end
listBtn.Text = "..."
task.spawn(function()
local res = call("List", sellSelected.uid, math.floor(price))
listBtn.Text = "Выставить на рынок"
toast(res.msg or (res.ok and "Listed" or "Failed"), res.ok and OK or WARN)
if res.ok then
sellSelected = nil
sellTitle.Text = "Ничего не выбрано"
sellInfo.Text = ""
priceBox.Text = ""
end
task.defer(refreshSell)
end)
end)
-- MY LISTINGS tab
local minePage = mPages.Mine
local mineHeader = ArtUI.label({ Position = UDim2.fromOffset(34, 20), Size = UDim2.fromOffset(1300, 40), Text = "", TextScaled = true, ZIndex = 3, Parent = minePage })
new("UITextSizeConstraint", { MaxTextSize = 26, Parent = mineHeader })
local mineList = new("ScrollingFrame", {
Position = UDim2.fromOffset(26, 70), Size = UDim2.fromOffset(1316, 616), BackgroundTransparency = 1, BorderSizePixel = 0, ZIndex = 3,
ScrollBarThickness = 10, ScrollBarImageColor3 = GOLD, AutomaticCanvasSize = Enum.AutomaticSize.Y, CanvasSize = UDim2.new(), Parent = minePage,
}, {
new("UIPadding", { PaddingTop = UDim.new(0, 6), PaddingLeft = UDim.new(0, 6), PaddingRight = UDim.new(0, 18), PaddingBottom = UDim.new(0, 6) }),
new("UIListLayout", { Padding = UDim.new(0, 12), SortOrder = Enum.SortOrder.LayoutOrder }),
})
local function refreshMine()
task.spawn(function()
local res = call("Mine")
clearList(mineList)
if not res.ok then mineHeader.Text = res.msg or "" return end
mineHeader.Text = "Активных лотов: " .. #res.items .. " / " .. (res.max or MK.MAX_LISTINGS) .. " · проданные лоты закрываются сами, осколки приходят автоматически"
for k, l in res.items do
local it = l.item
local r = Config.RarityById[it.Rarity]
local row = new("Frame", { Size = UDim2.new(1, 0, 0, 104), BackgroundColor3 = Color3.fromRGB(12, 56, 36), LayoutOrder = k, ZIndex = 3, Parent = mineList }, { corner(22), stroke(GOLD, 3) })
local mini = miniPattern(Config.ToyById[it.Toy].Mask, r.Color, 76, row)
mini.Position = UDim2.fromOffset(18, 14)
ArtUI.label({ Position = UDim2.fromOffset(116, 14), Size = UDim2.new(1, -420, 0, 40), Text = Config.ToyById[it.Toy].Name .. " · " .. r.Name .. (it.Variant and (" · " .. Config.VariantById[it.Variant].Name) or ""), TextSize = 32, TextColor3 = r.Color, Parent = row })
local left = math.max(0, l.expires - os.time())
ArtUI.label({ Position = UDim2.fromOffset(118, 58), Size = UDim2.new(1, -420, 0, 32), Text = fmtNum(l.price) .. " осколков · осталось " .. (left // 3600) .. "h " .. ((left % 3600) // 60) .. " min", TextSize = 24, TextColor3 = Color3.fromRGB(215, 230, 220), Parent = row }, 1.5)
local b = button({ AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -20, 0.5, 0), Size = UDim2.fromOffset(270, 66), Text = "Remove listing", TextSize = 26, Parent = row }, RED)
ArtUI.skin(b)
b.Activated:Connect(function()
b.Text = "..."
task.spawn(function()
local r2 = call("Cancel", l.id)
toast(r2.msg or "", r2.ok and OK or WARN)
refreshMine()
end)
end)
end
end)
end
local function showMarketTab(id)
mTab = id
for tid, b in mTabs do
ArtUI.setPill(b, tid == id and "gold" or "green")
mPages[tid].Visible = tid == id
end
mShards.Text = fmtNum(attr("Shards", 0)) .. " shards"
mGate.Text = attr("Level", 1) < MK.MIN_LEVEL and ("Покупать и продавать можно с " .. MK.MIN_LEVEL .. "-го уровня (смотреть — сразу)") or ""
if id == "Buy" then refreshBuy() elseif id == "Sell" then refreshSell() else refreshMine() end
end
for id, b in mTabs do b.Activated:Connect(function() showMarketTab(id) end) end
player:GetAttributeChangedSignal("Shards"):Connect(function() if market.overlay.Visible then mShards.Text = fmtNum(attr("Shards", 0)) .. " shards" end end)
task.spawn(function()
local inv = player:WaitForChild("OrnamentInventory")
local function changed() if market.overlay.Visible and mTab == "Sell" then task.defer(refreshSell) end end
inv.ChildAdded:Connect(changed)
inv.ChildRemoved:Connect(changed)
end)
local marketBtn = button({ Name = "MarketButton", Size = UDim2.fromOffset(210, 40), Text = "Market", TextSize = 17, LayoutOrder = 5, Parent = hudStack }, AMBER)
marketBtn.Activated:Connect(function()
if market.overlay.Visible then closeWindow() return end
openWindow(market, nil, function() showMarketTab(mTab) end)
end)
end
---------------------------------------------------------------- shop: decorations for the plot
local RunService = game:GetService("RunService")
local shopRemote = folder:WaitForChild("Shop")
local decorTemplates = folder:WaitForChild("Decor")
local XMAS = Color3.fromRGB(170, 28, 40)
local SW2, SH2 = 1000, 560
local store = makeWindow("ShopMenu", "Магазин для участка", SW2, SH2, XMAS)
local sp = store.panel
local storeShards = text({ AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -26, 0, 70), Size = UDim2.fromOffset(300, 30), Text = "", TextSize = 18, TextColor3 = ICE, TextXAlignment = Enum.TextXAlignment.Right, Parent = sp })
text({ Position = UDim2.fromOffset(26, 70), Size = UDim2.fromOffset(600, 30), Text = "Покупки появляются на твоём участке и остаются навсегда", TextSize = 15, Font = REGULAR, TextColor3 = MUTED, Parent = sp })
local cardsRow = new("Frame", { Position = UDim2.fromOffset(26, 112), Size = UDim2.new(1, -52, 1, -136), BackgroundTransparency = 1, Parent = sp }, {
new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, Padding = UDim.new(0, 16), SortOrder = Enum.SortOrder.LayoutOrder }),
})
local shopCards = {}
local spinning = {}
for _, it in Config.SHOP do
local card = new("Frame", { Size = UDim2.new(0.25, -12, 1, 0), BackgroundColor3 = SLOT, LayoutOrder = it.Order, Parent = cardsRow }, { corner(14) })
local st = stroke(EDGE, 2)
st.Parent = card
local vp = new("ViewportFrame", { Position = UDim2.fromOffset(10, 10), Size = UDim2.new(1, -20, 0, 190), BackgroundColor3 = NAVY, BackgroundTransparency = 0, Ambient = Color3.fromRGB(150, 150, 170), LightColor = Color3.fromRGB(255, 245, 230), LightDirection = Vector3.new(-1, -1.5, -1), Parent = card }, { corner(10) })
task.spawn(function()
-- MeshParts cloned before their mesh is loaded stay invisible in a ViewportFrame: preload first
local template = decorTemplates[it.Model]
pcall(function() game:GetService("ContentProvider"):PreloadAsync({ template }) end)
local model = template:Clone()
model:PivotTo(CFrame.new())
model.Parent = vp
local _, size = model:GetBoundingBox()
local cam = Instance.new("Camera")
cam.FieldOfView = 40
local dist = math.max(size.X, size.Y, size.Z) * 1.95
cam.CFrame = CFrame.lookAt(Vector3.new(0, size.Y * 0.7, dist), Vector3.new(0, size.Y * 0.48, 0))
cam.Parent = vp
vp.CurrentCamera = cam
table.insert(spinning, model)
end)
text({ Position = UDim2.fromOffset(12, 208), Size = UDim2.new(1, -24, 0, 24), Text = it.Name, TextSize = 18, TextXAlignment = Enum.TextXAlignment.Center, Parent = card })
text({ Position = UDim2.fromOffset(12, 236), Size = UDim2.new(1, -24, 0, 54), Text = it.Desc, TextWrapped = true, TextSize = 13, Font = REGULAR, TextColor3 = MUTED, TextXAlignment = Enum.TextXAlignment.Center, TextYAlignment = Enum.TextYAlignment.Top, Parent = card })
local priceRow = new("Frame", { Position = UDim2.new(0, 0, 1, -112), Size = UDim2.new(1, 0, 0, 34), BackgroundTransparency = 1, Parent = card })
local icon = shardIcon(30, priceRow)
icon.AnchorPoint = Vector2.new(1, 0.5)
icon.Position = UDim2.new(0.5, -28, 0.5, 0)
text({ AnchorPoint = Vector2.new(0, 0.5), Position = UDim2.new(0.5, -24, 0.5, 0), Size = UDim2.fromOffset(120, 30), Text = fmtNum(it.Price), TextSize = 24, TextColor3 = ICE, Parent = priceRow })
local b = button({ Name = "Buy" .. it.Id, Position = UDim2.new(0, 12, 1, -64), Size = UDim2.new(1, -24, 0, 50), Text = "Buy", TextSize = 18, Parent = card }, GREEN)
b.Activated:Connect(function()
if not b.Active then return end
b.Text = "..."
task.spawn(function()
local ok, res = pcall(shopRemote.InvokeServer, shopRemote, "Buy", it.Id)
res = (ok and type(res) == "table") and res or { ok = false, msg = "No connection to the shop" }
toast(res.msg or (res.ok and "Bought" or "Failed"), res.ok and OK or WARN)
end)
end)
shopCards[it.Id] = { card = card, stroke = st, button = b }
end
local function refreshStore()
local shards = attr("Shards", 0)
storeShards.Text = fmtNum(shards) .. " shards"
for _, it in Config.SHOP do
local c = shopCards[it.Id]
local owned = attr("Decor_" .. it.Id, false)
if owned then
c.button.Text = "Куплено ✓"
c.button.BackgroundColor3 = SLOT
c.button.Active, c.button.AutoButtonColor = false, false
c.stroke.Color, c.stroke.Thickness = OK, 3
else
local can = shards >= it.Price
c.button.Text = can and "Buy" or ("Need " .. fmtNum(it.Price - shards))
c.button.BackgroundColor3 = can and GREEN or Color3.fromRGB(70, 82, 120)
c.button.Active, c.button.AutoButtonColor = can, can
c.stroke.Color, c.stroke.Thickness = EDGE, 2
end
end
end
local spinAngle = 0
RunService.RenderStepped:Connect(function(dt)
if not store.overlay.Visible then return end
spinAngle += dt * 0.6
for _, m in spinning do m:PivotTo(CFrame.Angles(0, spinAngle, 0)) end
end)
player:GetAttributeChangedSignal("Shards"):Connect(function() if store.overlay.Visible then refreshStore() end end)
for _, it in Config.SHOP do
player:GetAttributeChangedSignal("Decor_" .. it.Id):Connect(function() if store.overlay.Visible then refreshStore() end end)
end
local shopBtn2 = button({ Name = "ShopButton", Size = UDim2.fromOffset(210, 40), Text = "Shop", TextSize = 17, LayoutOrder = 6, Parent = hudStack }, XMAS)
shopBtn2.Activated:Connect(function()
-- the New Year shop window lives in OrnamentShopUI; the old window here is only a fallback
local newShop = player.PlayerGui:FindFirstChild("OrnamentShopGui")
local toggleShop = newShop and newShop:FindFirstChild("Toggle")
if toggleShop then
if openMenu then closeWindow() end
toggleShop:Fire()
return
end
if store.overlay.Visible then closeWindow() return end
openWindow(store, nil, refreshStore)
end)
-- HUD: menu buttons in a compact 2-column grid
do
local grid = new("Frame", { Name = "Menu", Size = UDim2.fromOffset(210, 82), BackgroundTransparency = 1, LayoutOrder = 3, Parent = hudStack }, {
new("UIGridLayout", { CellSize = UDim2.fromOffset(102, 38), CellPadding = UDim2.fromOffset(6, 6), SortOrder = Enum.SortOrder.LayoutOrder }),
})
for k, name in { "WorkshopButton", "TradeButton", "MarketButton", "ShopButton" } do
local b = hudStack:FindFirstChild(name)
if b then
b.LayoutOrder = k
b.TextSize = 14
b.Parent = grid
end
end
end
---------------------------------------------------------------- premium shop (Robux)
local MarketplaceService = game:GetService("MarketplaceService")
local PREMIUM_COLOR = Color3.fromRGB(120, 70, 190)
local PW2, PH2 = 1000, 600
local premium = makeWindow("PremiumMenu", "Premium Shop", PW2, PH2, PREMIUM_COLOR)
local pp = premium.panel
-- art: premium_shop_bg - 4 blue cards (shard packs, gold tags on 2-4) + 2 purple cards (boosters); template pixels
ArtUI.artify(premium, ArtUI.IMG.premium)
local CRYSTAL_ID, CRYSTAL_RECT = "rbxassetid://105804941618750", { 54, 56, 206, 210 }
local function premiumBuyButton(card, item, x, y, w, h)
local btn = ArtUI.actionButton(card, false)
btn.Name = "Buy" .. item.Id
btn.Position = UDim2.fromOffset(x, y)
btn.Size = UDim2.fromOffset(w, h)
btn.ZIndex = 4
btn.Caption.Text = item.ProductId == 0 and "Soon" or ("R$ " .. item.Robux)
btn.Grey.Visible = item.ProductId == 0
btn.Activated:Connect(function()
if item.ProductId == 0 then
toast("Этот товар ещё не настроен (н... (truncated)