Files

1 line
13 KiB
JSON

{"file_path": "game.StarterPlayer.StarterPlayerScripts.RewardsUI", "className": "LocalScript", "edits": [{"old_string": "", "new_string": "-- Rewards window: daily login gifts (7-day cycle) + playtime gifts (9 tiers per day). HUD button cloned from\n-- the Workshop button (same look), red badge = gifts ready to claim. Server: OrnamentRewardsServer.\nlocal Players = game:GetService(\"Players\")\nlocal RS = game:GetService(\"ReplicatedStorage\")\nlocal TweenService = game:GetService(\"TweenService\")\nlocal player = Players.LocalPlayer\nlocal folder = RS:WaitForChild(\"OrnamentMachine\")\nlocal Config = require(folder:WaitForChild(\"Config\"))\nlocal remote = folder:WaitForChild(\"RewardsRemote\")\nlocal R = Config.REWARDS\n\nlocal FONT = Enum.Font.FredokaOne\nlocal GOLD, CREAM, WHITE = Color3.fromRGB(255, 205, 70), Color3.fromRGB(255, 244, 220), Color3.new(1, 1, 1)\nlocal PANEL, PANEL2 = Color3.fromRGB(18, 108, 62), Color3.fromRGB(12, 80, 46)\nlocal RED, DRED, GREENB, GREY = Color3.fromRGB(214, 40, 48), Color3.fromRGB(150, 22, 32), Color3.fromRGB(60, 190, 90), Color3.fromRGB(95, 105, 115)\n\nlocal function new(cls, props, kids)\n\tlocal o = Instance.new(cls)\n\tfor k, v in props or {} do if k ~= \"Parent\" then o[k] = v end end\n\tfor _, k in kids or {} do k.Parent = o end\n\tif props and props.Parent then o.Parent = props.Parent end\n\treturn o\nend\nlocal function corner(r) return new(\"UICorner\", { CornerRadius = UDim.new(0, r) }) end\nlocal function stroke(c, t) return new(\"UIStroke\", { Color = c, Thickness = t, ApplyStrokeMode = Enum.ApplyStrokeMode.Border }) end\nlocal function label(props)\n\tlocal l = new(\"TextLabel\", props)\n\tl.BackgroundTransparency, l.Font = 1, FONT\n\tl.TextColor3 = props.TextColor3 or WHITE\n\tl.TextScaled = true\n\tnew(\"UIStroke\", { Color = Color3.fromRGB(40, 20, 10), Thickness = 2, Parent = l })\n\treturn l\nend\n\nlocal function rewardLines(g)\n\tlocal t = {}\n\tif g.Shards then table.insert(t, { string.format(\"+%d shards\", g.Shards), Color3.fromRGB(120, 220, 255) }) end\n\tfor _, id in { \"Luck2\", \"Luck3\" } do\n\t\tlocal n = g.Boosters and g.Boosters[id]\n\t\tif n then table.insert(t, { string.format(id == \"Luck2\" and \"+%d Luck x2\" or \"+%d Luck x3\", n), id == \"Luck2\" and Color3.fromRGB(120, 235, 130) or GOLD }) end\n\tend\n\tif g.XP then table.insert(t, { string.format(\"+%d XP\", g.XP), Color3.fromRGB(255, 170, 255) }) end\n\treturn t\nend\nlocal function timeText(m)\n\tif m < 60 then return string.format(\"%d min\", m) end\n\tif m % 60 == 0 then return string.format(\"%d h\", m // 60) end\n\treturn string.format(\"%d h %d min\", m // 60, m % 60)\nend\nlocal function icon(g)\n\tif g.Boosters and g.Boosters.Luck3 then return \"🍀\" elseif g.Boosters then return \"☘️\" elseif (g.Shards or 0) >= 100 then return \"💎\" else return \"❄️\" end\nend\n\n---------------------------------------------------------------- window\nlocal gui = new(\"ScreenGui\", { Name = \"RewardsGui\", ResetOnSpawn = false, DisplayOrder = 30, Enabled = false,\n\tZIndexBehavior = Enum.ZIndexBehavior.Sibling, Parent = player:WaitForChild(\"PlayerGui\") })\nlocal dim = new(\"TextButton\", { Text = \"\", AutoButtonColor = false, Size = UDim2.fromScale(1, 1), BackgroundColor3 = Color3.new(0, 0, 0),\n\tBackgroundTransparency = 0.45, Parent = gui })\nlocal win = new(\"Frame\", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.52), Size = UDim2.fromOffset(940, 600),\n\tBackgroundColor3 = PANEL, Parent = gui }, { corner(30), stroke(GOLD, 6),\n\tnew(\"UIGradient\", { Rotation = 90, Color = ColorSequence.new(PANEL, PANEL2) }) })\nlocal scale = new(\"UIScale\", { Parent = win })\nlocal function rescale()\n\tlocal v = workspace.CurrentCamera.ViewportSize\n\tscale.Scale = math.min(v.X / 1010, v.Y / 680, 1.15)\nend\nrescale(); workspace.CurrentCamera:GetPropertyChangedSignal(\"ViewportSize\"):Connect(rescale)\n-- snowy top edge + title ribbon\nnew(\"Frame\", { Position = UDim2.fromOffset(10, -10), Size = UDim2.new(1, -20, 0, 34), BackgroundColor3 = Color3.fromRGB(245, 250, 255), Parent = win }, { corner(17) })\nlocal ribbon = new(\"Frame\", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.new(0.5, 0, 0, 0), Size = UDim2.fromOffset(380, 86),\n\tBackgroundColor3 = RED, Parent = win }, { corner(26), stroke(GOLD, 5), new(\"UIGradient\", { Rotation = 90, Color = ColorSequence.new(RED, DRED) }) })\nlabel({ Text = \"🎁 Rewards\", Position = UDim2.fromOffset(20, 10), Size = UDim2.new(1, -40, 1, -20), TextColor3 = GOLD, Parent = ribbon })\nlocal close = new(\"TextButton\", { Text = \"✕\", Font = FONT, TextScaled = true, TextColor3 = WHITE, AnchorPoint = Vector2.new(0.5, 0.5),\n\tPosition = UDim2.new(1, -18, 0, 18), Size = UDim2.fromOffset(70, 70), BackgroundColor3 = RED, Parent = win }, { corner(20), stroke(WHITE, 4) })\n\nlocal tabs, pages, current = {}, {}, \"Daily\"\nlocal function tabButton(id, text, x)\n\tlocal b = new(\"TextButton\", { Text = \"\", AutoButtonColor = true, Position = UDim2.fromOffset(x, 62), Size = UDim2.fromOffset(300, 64),\n\t\tBackgroundColor3 = RED, Parent = win }, { corner(22), stroke(GOLD, 4) })\n\tlabel({ Text = text, Position = UDim2.fromOffset(12, 8), Size = UDim2.new(1, -24, 1, -16), Parent = b })\n\ttabs[id] = b\n\treturn b\nend\ntabButton(\"Daily\", \"Daily login\", 150); tabButton(\"Play\", \"Playtime\", 490)\n\nlocal hint = label({ Text = \"\", Position = UDim2.new(0, 40, 1, -62), Size = UDim2.new(1, -80, 0, 34), TextColor3 = CREAM, Parent = win })\nhint.UIStroke.Thickness = 1.5\n\nlocal function page(id, cell, cols)\n\tlocal f = new(\"Frame\", { Position = UDim2.fromOffset(30, 146), Size = UDim2.new(1, -60, 1, -220), BackgroundTransparency = 1, Visible = false, Parent = win })\n\tnew(\"UIGridLayout\", { CellSize = cell, CellPadding = UDim2.fromOffset(14, 14), HorizontalAlignment = Enum.HorizontalAlignment.Center,\n\t\tVerticalAlignment = Enum.VerticalAlignment.Center, SortOrder = Enum.SortOrder.LayoutOrder, FillDirectionMaxCells = cols, Parent = f })\n\tpages[id] = f\n\treturn f\nend\nlocal function card(parent, order, title, g, onClaim)\n\tlocal c = new(\"Frame\", { LayoutOrder = order, BackgroundColor3 = Color3.fromRGB(196, 32, 42), Parent = parent }, {\n\t\tcorner(22), stroke(GOLD, 4), new(\"UIGradient\", { Rotation = 90, Color = ColorSequence.new(Color3.fromRGB(230, 60, 60), Color3.fromRGB(160, 20, 32)) }) })\n\tnew(\"Frame\", { Position = UDim2.fromOffset(6, -6), Size = UDim2.new(1, -12, 0, 18), BackgroundColor3 = Color3.fromRGB(245, 250, 255), Parent = c }, { corner(9) })\n\tlabel({ Text = title, Position = UDim2.fromOffset(8, 14), Size = UDim2.new(1, -16, 0, 30), TextColor3 = GOLD, Parent = c })\n\tlabel({ Text = icon(g), Position = UDim2.fromOffset(8, 46), Size = UDim2.new(1, -16, 0, 44), Parent = c })\n\tlocal list = new(\"Frame\", { Position = UDim2.fromOffset(8, 94), Size = UDim2.new(1, -16, 1, -150), BackgroundTransparency = 1, Parent = c },\n\t\t{ new(\"UIListLayout\", { HorizontalAlignment = Enum.HorizontalAlignment.Center, VerticalAlignment = Enum.VerticalAlignment.Center, Padding = UDim.new(0, 2) }) })\n\tlocal lines = rewardLines(g)\n\tfor _, ln in lines do label({ Text = ln[1], TextColor3 = ln[2], Size = UDim2.new(1, 0, 1 / math.max(#lines, 2), -2), Parent = list }) end\n\tlocal btn = new(\"TextButton\", { Text = \"\", AutoButtonColor = true, AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 0, 1, -10),\n\t\tSize = UDim2.new(1, -20, 0, 42), BackgroundColor3 = GREENB, Parent = c }, { corner(14), stroke(Color3.fromRGB(20, 60, 30), 2.5) })\n\tlocal bl = label({ Text = \"Claim\", Position = UDim2.fromOffset(6, 4), Size = UDim2.new(1, -12, 1, -8), Parent = btn })\n\tbtn.MouseButton1Click:Connect(onClaim)\n\treturn { frame = c, btn = btn, text = bl }\nend\n\nlocal busy = false\nlocal function claim(action, idx)\n\tif busy then return end\n\tbusy = true\n\tlocal ok, res = pcall(function() return remote:InvokeServer(action, idx) end)\n\tbusy = false\n\treturn ok and res\nend\n\nlocal dailyCards, playCards = {}, {}\nlocal dp = page(\"Daily\", UDim2.fromOffset(190, 190), 4)\nfor i, g in R.LOGIN do dailyCards[i] = card(dp, i, string.format(\"Day %d\", i), g, function() claim(\"Login\") end) end\nlocal pp = page(\"Play\", UDim2.fromOffset(152, 188), 5)\nfor i, g in R.PLAYTIME do playCards[i] = card(pp, i, timeText(g.Minutes), g, function() claim(\"Play\", i) end) end\n\n---------------------------------------------------------------- state -> cards\nlocal playBase, playAt = 0, os.clock()\nlocal function attr(k, d) local v = player:GetAttribute(k); if v == nil then return d end return v end\nlocal function playSec() return attr(\"RW_PlaySec\", 0) + math.min(os.clock() - playAt, 10) end\nplayer:GetAttributeChangedSignal(\"RW_PlaySec\"):Connect(function() playAt = os.clock() end)\nlocal function setBtn(cd, state, text)\n\tcd.text.Text = text\n\tcd.btn.Active = state == \"ready\"\n\tcd.btn.AutoButtonColor = state == \"ready\"\n\tcd.btn.BackgroundColor3 = state == \"ready\" and GREENB or state == \"done\" and Color3.fromRGB(40, 120, 70) or GREY\n\tcd.frame.BackgroundTransparency = state == \"done\" and 0.35 or 0\nend\nlocal function untilMidnight()\n\tlocal t = os.date(\"!*t\")\n\treturn 86400 - (t.hour * 3600 + t.min * 60 + t.sec)\nend\nlocal function countdown(s)\n\ts = math.max(0, math.floor(s))\n\tif s >= 3600 then return string.format(\"in %d:%02d:%02d\", s // 3600, s // 60 % 60, s % 60) end\n\treturn string.format(\"in %d:%02d\", s // 60, s % 60)\nend\nlocal function readyCount()\n\tlocal n = attr(\"RW_LoginReady\", false) and 1 or 0\n\tlocal mask, sec = attr(\"RW_PlayClaimed\", 0), playSec()\n\tfor i, g in R.PLAYTIME do\n\t\tif math.floor(mask / 2 ^ (i - 1)) % 2 == 0 and sec >= g.Minutes * 60 then n += 1 end\n\tend\n\treturn n\nend\nlocal function refresh()\n\tlocal total, ready = attr(\"RW_LoginDay\", 0), attr(\"RW_LoginReady\", false)\n\tlocal n = #R.LOGIN\n\tlocal done = total % n -- gifts claimed in the current cycle\n\tif not ready and done == 0 and total > 0 then done = n end -- day 7 was claimed today\n\tfor i, cd in dailyCards do\n\t\tif i <= done then setBtn(cd, \"done\", \"Claimed\")\n\t\telseif i == done + 1 and ready then setBtn(cd, \"ready\", \"Claim\")\n\t\telseif i == done + 1 then setBtn(cd, \"wait\", countdown(untilMidnight()))\n\t\telse setBtn(cd, \"wait\", i == done + 2 and not ready and \"Tomorrow\" or string.format(\"Day %d\", i)) end\n\tend\n\tlocal mask, sec = attr(\"RW_PlayClaimed\", 0), playSec()\n\tfor i, cd in playCards do\n\t\tlocal need = R.PLAYTIME[i].Minutes * 60\n\t\tif math.floor(mask / 2 ^ (i - 1)) % 2 == 1 then setBtn(cd, \"done\", \"Claimed\")\n\t\telseif sec >= need then setBtn(cd, \"ready\", \"Claim\")\n\t\telse setBtn(cd, \"wait\", countdown(need - sec)) end\n\tend\n\tif current == \"Daily\" then\n\t\thint.Text = \"Come in every day for a gift! Missing a day doesn't reset your progress.\"\n\telse\n\t\tlocal s = math.floor(sec)\n\t\thint.Text = string.format(\"Today's playtime: %d:%02d · resets at 00:00 UTC\", s // 3600, s // 60 % 60)\n\tend\nend\nlocal function show(id)\n\tcurrent = id\n\tfor k, f in pages do f.Visible = k == id end\n\tfor k, b in tabs do b.BackgroundColor3 = k == id and Color3.fromRGB(240, 170, 40) or RED end\n\trefresh()\nend\nfor id, b in tabs do b.MouseButton1Click:Connect(function() show(id) end) end\nlocal function open(id)\n\tshow(id or (attr(\"RW_LoginReady\", false) and \"Daily\" or current))\n\tgui.Enabled = true\n\twin.Size = UDim2.fromOffset(846, 540)\n\tTweenService:Create(win, TweenInfo.new(0.25, Enum.EasingStyle.Back), { Size = UDim2.fromOffset(940, 600) }):Play()\nend\nlocal function closeWin() gui.Enabled = false end\nclose.MouseButton1Click:Connect(closeWin)\ndim.MouseButton1Click:Connect(closeWin)\n\n---------------------------------------------------------------- HUD button (copy of the Workshop button)\ntask.spawn(function()\n\tlocal menu = player.PlayerGui:WaitForChild(\"OrnamentCraftGui\"):WaitForChild(\"Hud\"):WaitForChild(\"Menu\")\n\tlocal tpl = menu:WaitForChild(\"WorkshopButton\", 30)\n\tif not tpl then return end\n\tlocal b = tpl:Clone()\n\tb.Name = \"RewardsButton\"\n\tb.LayoutOrder = 999\n\tlocal badge\n\tfor _, d in b:GetDescendants() do\n\t\tif d:IsA(\"TextLabel\") and d.Text == \"Workshop\" then d.Text = \"Rewards\"\n\t\telseif d:IsA(\"TextLabel\") and tonumber(d.Text) then badge = d\n\t\telseif d:IsA(\"ImageLabel\") then\n\t\t\td.ImageTransparency = 1\n\t\t\tlabel({ Text = \"🎁\", Size = UDim2.fromScale(1, 1), Parent = d })\n\t\tend\n\tend\n\tb.Parent = menu\n\tb.MouseButton1Click:Connect(function() if gui.Enabled then closeWin() else open() end end)\n\tlocal badgeBox = badge and badge.Parent\n\twhile true do\n\t\tlocal n = readyCount()\n\t\tif badge then badge.Text = tostring(n); if badgeBox and badgeBox:IsA(\"GuiObject\") then badgeBox.Visible = n > 0 end end\n\t\tif gui.Enabled then refresh() end\n\t\ttask.wait(1)\n\tend\nend)\n\n-- today's login gift waiting -> open the window once a few seconds after joining\ntask.delay(6, function()\n\tif attr(\"RW_LoginReady\", false) and not gui.Enabled then open(\"Daily\") end\nend)\n"}], "studio_id": "0411fa4a-b0e9-4eb3-8d9b-e8e08277ee91", "datamodel_type": "Edit"}