From 37f60b04ffbf18d6d4391efc1aa1ecb688574de2 Mon Sep 17 00:00:00 2001 From: Lewin Kelly Date: Sun, 24 Mar 2024 21:33:08 +0000 Subject: [PATCH] Improvements to debug console corescript and order places correctly on games page --- Modules/DebugConsole.luau | 233 --------------------- defs.d.lua | 2 +- luau/20000001.luau | 429 ++++++++++++++++++++++++++++++++++++++ luau/37801172.luau | 13 +- luau/97188756.luau | 18 +- 5 files changed, 449 insertions(+), 246 deletions(-) delete mode 100644 Modules/DebugConsole.luau create mode 100644 luau/20000001.luau diff --git a/Modules/DebugConsole.luau b/Modules/DebugConsole.luau deleted file mode 100644 index df8b4f8..0000000 --- a/Modules/DebugConsole.luau +++ /dev/null @@ -1,233 +0,0 @@ ---!strict - -local Players = game:GetService "Players" -local MaxLength = 35 - -local New = (require "../Modules/New").New - -local logEvent: BindableEvent - -local docs: { [string]: { string } } = { - help = { - "help()", - "You've already found this command!", - }, - printTable = { - "printTable(t: { [any]: any }, max: number?)", - "Prints the contents of a table to the console.", - "`max` is the maximum number of entries to print. If not provided, all", - "entries are printed.", - }, - exit = { - "exit()", - "Exits the debug console.", - }, -} - -local utility = { - help = function() - for _, doc in pairs(docs) do - logEvent:Fire(doc[1], Color3.new(1, 1, 0.3)) - for i = 2, #doc do - logEvent:Fire("\t" .. doc[i], Color3.new(1, 1, 1)) - end - end - end, - printTable = function(t: { [any]: any }, max: number?) - assert(type(t) == "table", "Expected table, got " .. type(t)) - - local num = max or math.huge - local len = 0 - for k, v in pairs(t) do - len += 1 - if len < num then - logEvent:Fire(tostring(k) .. " = " .. tostring(v)) - end - end - if len >= num then - logEvent:Fire("... and " .. tostring(len - num) .. " more") - end - end, - exit = function() - logEvent:Fire("Goodbye!", Color3.new(1, 1, 0.3)) - wait(0.5) - local debug = game.CoreGui:FindFirstChild "Debug console" :: ScreenGui - debug:Destroy() - end, -} - -return function(parent: CoreGui) - if not Players.LocalPlayer or Players.LocalPlayer.Name ~= "Heliodex" then -- Don't show the debug console for anyone but me - return - end - - logEvent = logEvent - or New "BindableEvent" { - Name = "Log", - Parent = game, - } - - local screen = New "ScreenGui" { - Name = "Debug console", - Parent = parent, - } - - local frame = New "Frame" { - Name = "Frame", - BackgroundTransparency = 1, - Position = UDim2.new(0, 0, 0.2, 0), - Size = UDim2.new(0.25, 0, 0.7, 0), - Parent = screen, - } - - local console = New "Frame" { - Name = "Console", - BackgroundColor3 = Color3.new(0, 0, 0), - BackgroundTransparency = 0.5, - BorderSizePixel = 0, - Position = UDim2.new(0, 0, 0, 0), - Size = UDim2.new(1, 0, 1, -30), - Parent = frame, - } - - local logLines = {} - local logLineInstances: { TextLabel } = {} - for i = 1, MaxLength do - table.insert(logLines, { - Text = "", - Colour = Color3.new(1, 1, 1), - }) - table.insert( - logLineInstances, - New "TextLabel" { - Name = "LogLine", - BackgroundTransparency = 1, - Font = Enum.Font.SourceSans, - FontSize = Enum.FontSize.Size18, - Position = UDim2.new(0, 0, 0, (i - 1) * 18), - Size = UDim2.new(1, 0, 0, 18), - Text = "", - TextColor3 = Color3.new(1, 1, 1), - TextXAlignment = Enum.TextXAlignment.Left, - Parent = console, - } - ) - end - - local function recomputeLogLines() - for i, line in ipairs(logLines) do - logLineInstances[i].Text = line.Text - logLineInstances[i].TextColor3 = line.Colour or Color3.new(1, 1, 1) - end - end - - logEvent.Event:connect(function(text: string, colour: Color3?) - table.insert(logLines, { - Text = text, - Colour = colour or Color3.new(1, 1, 1), - }) - if #logLines > MaxLength then - table.remove(logLines, 1) - end - - recomputeLogLines() - end) - - local input = New "TextBox" { - Name = "Input", - BackgroundColor3 = Color3.new(0.2, 0.2, 0.2), - BackgroundTransparency = 0.2, - BorderSizePixel = 0, - Position = UDim2.new(0, 0, 1, -30), - Size = UDim2.new(1, -30, 0, 30), - Font = Enum.Font.SourceSans, - FontSize = Enum.FontSize.Size18, - Text = "", - TextColor3 = Color3.new(1, 1, 1), - TextXAlignment = Enum.TextXAlignment.Left, - ClearTextOnFocus = false, - Parent = frame, - } - - local upButton = New "TextButton" { - Name = "UpButton", - BackgroundColor3 = Color3.new(0.2, 0.2, 0.2), - BackgroundTransparency = 0.2, - BorderSizePixel = 0, - Position = UDim2.new(1, -30, 1, -30), - Size = UDim2.new(0, 30, 0, 30), - Font = Enum.Font.SourceSans, - FontSize = Enum.FontSize.Size24, - Text = "^", - TextColor3 = Color3.new(1, 1, 1), - Parent = frame, - } - - local history = {} - local historyPos = 1 - - -- on upButton pressed, go back in history - upButton.MouseButton1Click:connect(function() - if historyPos > #history then - return - end - - input.Text = history[historyPos] - historyPos += 1 - end) - - input.FocusLost:connect(function(enterPressed) - if enterPressed then - historyPos = 1 - local text = input.Text - table.insert(history, 1, text) - logEvent:Fire("> " .. text) - - -- run the command - local fn = loadstring(text) - - if fn then - local env = getfenv(fn) - for k, v in pairs(utility) do - env[k] = v - end - setfenv(fn, env) - - local success, output = ypcall(fn) - if success then - logEvent:Fire( - "= " .. tostring(output), - Color3.new(0.5, 1, 0.5) - ) - else - logEvent:Fire( - "! " .. tostring(output), - Color3.new(1, 0.5, 0.5) - ) - end - else - logEvent:Fire("Invalid command", Color3.new(1, 0.3, 0.3)) - end - - input.Text = "" - input.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2) - end - end) - - input.Changed:connect(function(property) - if property ~= "Text" or input.Text == "" then - return - end - - input.BackgroundColor3 = Color3.new(0, 0, 0) - end) - - logEvent:Fire("[Reading access...]", Color3.new(0.5, 0.5, 0.5)) -- haxor text - logEvent:Fire("[Access granted.]", Color3.new(0.5, 1, 0.5)) - logEvent:Fire( - "Welcome to the Mercury Debug Console!", - Color3.new(1, 1, 0.3) - ) - logEvent:Fire("Type `help()` for a list of commands.", Color3.new(1, 1, 1)) - logEvent:Fire("") -end diff --git a/defs.d.lua b/defs.d.lua index 3cb1e5a..3e7ff3f 100644 --- a/defs.d.lua +++ b/defs.d.lua @@ -3787,7 +3787,7 @@ declare class BodyAngularVelocity extends BodyMover end declare class BodyForce extends BodyMover - Force: Vector3 + force: Vector3 end declare class BodyGyro extends BodyMover diff --git a/luau/20000001.luau b/luau/20000001.luau new file mode 100644 index 0000000..c7e40dd --- /dev/null +++ b/luau/20000001.luau @@ -0,0 +1,429 @@ +--!strict +-- Never trust the client + +local CoreGui = game:GetService "CoreGui" +local Players = game:GetService "Players" +local RunService = game:GetService "RunService" +local MaxLength = 35 + +local New = (require "../Modules/New").New + +local logEvent: BindableEvent + +local function Colour3(r: number, g: number, b: number) + return Color3.new(r / 255, g / 255, b / 255) +end + +local docs = { + { + "printTable(t: { [any]: any }, max: number?)", + "Prints the contents of a table to the console.", + "`max` - the maximum number of entries to print.", + "If not provided, all entries are printed.", + }, + { + "setWalkspeed(speed: number, plr: string?)", + "Sets the walkspeed of a player. Go h4x0r mode!", + "`speed` - the new walkspeed.", + "`plr` - the name of the player to set the walkspeed of.", + "If not provided, sets your own walkspeed.", + }, + { + "setHealth(health: number, plr: string?)", + "Sets the health of a player. Become invincible!", + "`health` - the new health value. Increases max health if necessary.", + "`plr` - the name of the player to set the health of.", + "If not provided, sets your own health.", + }, + { + "setMaxHealth(health: number, plr: string?)", + "Sets the maximum health of a player.", + "`health` - the new max health value.", + "`plr` - the name of the player to set the max health of.", + "If not provided, sets your own max health.", + }, + { + "setGravity(multi: number, plr: string?)", + "Sets the gravity of a player. Float like a feather!", + "`multi` - the multiplier to apply to gravity. 1 is normal, 2 is double,", + "0.5 is half, etc. Beware of negative numbers!", + "`plr` - the name of the player to set the gravity of.", + "If not provided, changes your own gravity.", + }, + { + "sit(plr: string?)", + "Sits a player down.", + "`plr` - the name of the player to set the sitting state of.", + "If not provided, sets your own sitting state.", + }, + { + "platformStand(plr: string?)", + "Sets a player to stand on a platform.", + "`plr` - the name of the player to set the platform standing state of.", + "If not provided, sets your own platform standing state.", + }, + { + "stand(plr: string?)", + "Stands a player up, and removes platform standing.", + "`plr` - the name of the player to set the standing state of.", + "If not provided, sets your own standing state.", + }, + { + "explode(plr: string?)", + "Detonates a player, killing them instantly, and probably anyone nearby", + "them too.", + "`plr` - the name of the player to explode.", + "If not provided, well... you know the deal.", + }, + { + "help(max: number?)", + "You've already found this command!", + "`max` - the maximum number of entries to print.", + "If not provided, all entries are printed.", + }, + { + "exit()", + "Exits the debug console. Watch out, you can't get back in!", + }, +} + +local function Fire(should: boolean, ...: any) + if should then + logEvent:Fire(...) + end +end + +local utility = { + CoreGui = CoreGui, -- convenience/shorthands + Players = Players, + RunService = RunService, +} + +local function Assert(condition: any, message: string) + if not condition then + error(message, -1) + end +end + +local j = print + +function utility.print(...) + local args = { ... } + for i, v in ipairs(args) do + args[i] = tostring(v) + end + local p = table.concat(args, " ") + j(p) + logEvent:Fire(p) +end + +function utility.printTable(t: { [any]: any }, max: number?) + assert(type(t) == "table", "Expected table, got " .. type(t)) + + local num = max or math.huge + local len = 0 + + for k, v in pairs(t) do + len += 1 + Fire(len < num, tostring(k) .. " = " .. tostring(v)) + end + if len >= num then + logEvent:Fire("... and " .. tostring(len - num) .. " more") + end +end + +-- I will not drown in a sea of tiny functions, I promise +local function getPlayerByUsername(username: string?) + local player = (username and Players:FindFirstChild(username)) :: Player + Assert(not username or player, "Player not found") + player = player or Players.LocalPlayer + Assert(player, "No player provided and no local player found") + return player +end + +local function getCharacterByUsername(username: string?) + local player = getPlayerByUsername(username) + return player.Character or player.CharacterAdded:wait(), player +end + +local function getHumanoidByUsername(username: string?) + local character, player = getCharacterByUsername(username) + return character:WaitForChild "Humanoid" :: Humanoid, character, player +end + +function utility.setWalkspeed(speed: number, plr: string?) + Assert(type(speed) == "number", "Expected number, got " .. type(speed)) + + local humanoid = getHumanoidByUsername(plr) + + humanoid.WalkSpeed = speed +end + +function utility.setHealth(health: number, plr: string?) + Assert(type(health) == "number", "Expected number, got " .. type(health)) + + local humanoid = getHumanoidByUsername(plr) + + if humanoid.MaxHealth < health then + humanoid.MaxHealth = health + end + humanoid.Health = health +end + +function utility.setMaxHealth(health: number, plr: string?) + Assert(type(health) == "number", "Expected number, got " .. type(health)) + + local humanoid = getHumanoidByUsername(plr) + + humanoid.MaxHealth = health +end + +function utility.sit(plr: string?) + local humanoid = getHumanoidByUsername(plr) + humanoid.Sit = true +end + +function utility.platformStand(plr: string?) + local humanoid = getHumanoidByUsername(plr) + humanoid.PlatformStand = true +end + +function utility.stand(plr: string?) + local humanoid = getHumanoidByUsername(plr) + humanoid.Sit = false + humanoid.PlatformStand = false +end + +function utility.explode(plr: string?) + local character = getCharacterByUsername(plr) + local torso = character:FindFirstChild "Torso" :: Part + Assert(torso, "No torso found in character, required to explode") + + New "Explosion" { + ExplosionType = Enum.ExplosionType.NoCraters, + Parent = character, + Position = torso.Position, + BlastPressure = 15e5, -- engineering moment + BlastRadius = 2, + } +end + +local grav = 3372 -- just enough keep you on the ground, as long as you don't jump + +function utility.setGravity(multi: number, plr: string?) + assert(type(multi) == "number", "Expected number, got " .. type(multi)) + + local character = getCharacterByUsername(plr) + local torso = character:FindFirstChild "Torso" :: Part + Assert(torso, "No torso found in character, required to apply gravity") + + local bodyForce = torso:FindFirstChild "Gravity" + or New "BodyForce" { + Name = "Gravity", + Parent = torso, + } + bodyForce.force = Vector3.new(0, grav * (1 - multi), 0) +end + +function utility.help(max: number?) + local num = max or math.huge + local len = 0 + + for _, doc in pairs(docs) do + if len < num then + RunService.RenderStepped:wait() + end + Fire(len < num, doc[1], Color3.new(1, 1, 0.3)) + len += 1 + for i = 2, #doc do + Fire(len < num, "\t" .. doc[i], Color3.new(1, 1, 1)) + len += 1 + end + end + if len >= num then + logEvent:Fire("... and " .. tostring(len - num) .. " more") + end +end + +function utility.exit() + logEvent:Fire("Goodbye!", Color3.new(1, 1, 0.3)) + + for i = 1, MaxLength do + logEvent:Fire() + RunService.RenderStepped:wait() + end + + local debug = game.CoreGui:FindFirstChild "Debug console" :: ScreenGui + debug:Destroy() +end + +if not Players.LocalPlayer or Players.LocalPlayer.Name ~= "Heliodex" then -- Don't show the debug console for anyone but me + return +end + +logEvent = logEvent or New "BindableEvent" { + Name = "Log", + Parent = game, +} + +local screen = New "ScreenGui" { + Name = "Debug console", + Parent = CoreGui, +} + +local frame = New "Frame" { + Name = "Frame", + BackgroundTransparency = 1, + Position = UDim2.new(0, 0, 0.2, 0), + Size = UDim2.new(0.25, 0, 0.7, 0), + Parent = screen, +} + +local console = New "Frame" { + Name = "Console", + BackgroundColor3 = Color3.new(0, 0, 0), + BackgroundTransparency = 0.5, + BorderSizePixel = 0, + Position = UDim2.new(0, 0, 0, 0), + Size = UDim2.new(1, 0, 1, -30), + Parent = frame, +} + +local logLines = {} +local logLineInstances: { TextLabel } = {} +for i = 1, MaxLength do + table.insert(logLines, { + Text = "", + Colour = Color3.new(1, 1, 1), + }) + table.insert( + logLineInstances, + New "TextLabel" { + Name = "LogLine", + BackgroundTransparency = 1, + Font = Enum.Font.SourceSans, + FontSize = Enum.FontSize.Size18, + Position = UDim2.new(0, 0, 0, (i - 1) * 18), + Size = UDim2.new(1, 0, 0, 18), + Text = "", + TextColor3 = Color3.new(1, 1, 1), + TextXAlignment = Enum.TextXAlignment.Left, + Parent = console, + } + ) +end + +local function recomputeLogLines() + for i, line in ipairs(logLines) do + logLineInstances[i].Text = " " .. line.Text -- yeah pad + logLineInstances[i].TextColor3 = line.Colour or Color3.new(1, 1, 1) + end +end + +logEvent.Event:connect(function(text: string?, colour: Color3?) + table.insert(logLines, { + Text = text or "", + Colour = colour or Color3.new(1, 1, 1), + }) + if #logLines > MaxLength then + table.remove(logLines, 1) + end + + recomputeLogLines() +end) + +local input = New "TextBox" { + Name = "Input", + BackgroundColor3 = Color3.new(0.2, 0.2, 0.2), + BackgroundTransparency = 0.2, + BorderSizePixel = 0, + Position = UDim2.new(0, 0, 1, -30), + Size = UDim2.new(1, -30, 0, 30), + Font = Enum.Font.SourceSans, + FontSize = Enum.FontSize.Size18, + Text = "", + TextColor3 = Color3.new(1, 1, 1), + TextXAlignment = Enum.TextXAlignment.Left, + ClearTextOnFocus = false, + Parent = frame, +} + +local upButton = New "TextButton" { + Name = "UpButton", + BackgroundColor3 = Color3.new(0.2, 0.2, 0.2), + BackgroundTransparency = 0.2, + BorderSizePixel = 0, + Position = UDim2.new(1, -30, 1, -30), + Size = UDim2.new(0, 30, 0, 30), + Font = Enum.Font.SourceSans, + FontSize = Enum.FontSize.Size24, + Text = "^", + TextColor3 = Color3.new(1, 1, 1), + Parent = frame, +} + +local history = {} +local historyPos = 1 + +-- on upButton pressed, go back in history +upButton.MouseButton1Click:connect(function() + if historyPos > #history then + return + end + + input.Text = history[historyPos] + historyPos += 1 +end) + +input.FocusLost:connect(function(enterPressed) + if enterPressed then + historyPos = 1 + local text = input.Text + table.insert(history, 1, text) + logEvent:Fire("> " .. text) + + -- run the command + local fn = loadstring(text) + + if fn then + local env = getfenv(fn) + for k, v in pairs(utility) do + env[k] = v + end + setfenv(fn, env) + + local success, output = ypcall(fn) + if success then + logEvent:Fire("= " .. tostring(output), Color3.new(0.5, 1, 0.5)) + else + logEvent:Fire("! " .. tostring(output), Color3.new(1, 0.5, 0.5)) + end + else + logEvent:Fire("Invalid command", Color3.new(1, 0.3, 0.3)) + end + + input.Text = "" + input.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2) + end +end) + +input.Changed:connect(function(property) + if property ~= "Text" or input.Text == "" then + return + end + + input.BackgroundColor3 = Color3.new(0, 0, 0) +end) + +local welcome: { { any } } = { + { "[Reading access...]", Color3.new(0.6, 0.6, 0.6) }, -- haxor text + { "[Access granted.]", Color3.new(0.5, 1, 0.5) }, -- i'm in + { "Welcome to the Mercury Debug Console!", Colour3(139, 82, 255) }, -- mercury light purple + { "Run `help()` for a list of functions.", Color3.new(1, 1, 1) }, + { "" }, +} + +for _, line in ipairs(welcome) do + logEvent:Fire(unpack(line)) + RunService.RenderStepped:wait() +end diff --git a/luau/37801172.luau b/luau/37801172.luau index 5fda8a5..0c0dac8 100644 --- a/luau/37801172.luau +++ b/luau/37801172.luau @@ -2,11 +2,18 @@ -- Script Context.StarterScript print "[Mercury]: Loaded corescript 37801172" -local ScriptContext = game:GetService "ScriptContext" local CoreGui = game:GetService "CoreGui" +local Players = game:GetService "Players" +local ScriptContext = game:GetService "ScriptContext" -local Debug = require "../Modules/DebugConsole" -Debug(CoreGui) +if Players.LocalPlayer and Players.LocalPlayer.Name == "Heliodex" then + -- Don't show the debug console for anyone but me + ScriptContext:AddCoreScript( + 20000001, + ScriptContext, + "CoreScripts/DebugConsole" + ) +end -- Creates all neccessary scripts for the gui on initial load, everything except build tools -- Please note that these are loaded in a specific order to diminish errors/perceived load time by user diff --git a/luau/97188756.luau b/luau/97188756.luau index 0655cef..af22a98 100644 --- a/luau/97188756.luau +++ b/luau/97188756.luau @@ -28,8 +28,8 @@ end local Camera = Game.Workspace.CurrentCamera -- Services -local CoreGuiService = Game:GetService "CoreGui" -local PlayersService = Game:GetService "Players" +local CoreGui = Game:GetService "CoreGui" +local Players = Game:GetService "Players" local GuiService = Game:GetService "GuiService" -- Lua Enums @@ -653,7 +653,7 @@ end -- Create the initial Chat stuff -- Done only once function Chat:CreateGui() - self.Gui = WaitForChild(CoreGuiService, "RobloxGui") + self.Gui = WaitForChild(CoreGui, "RobloxGui") self.Frame = New "Frame" { Name = "ChatFrame", --Size = self.Configuration.Size; @@ -716,9 +716,9 @@ function Chat:CreateGui() local cText = self.ChatBar.Text if string.sub(self.ChatBar.Text, 1, 1) == "%" then cText = "(TEAM) " .. string.sub(cText, 2, #cText) - pcall(PlayersService.TeamChat, PlayersService, cText) + pcall(Players.TeamChat, Players, cText) else - pcall(PlayersService.Chat, PlayersService, cText) + pcall(Players.Chat, Players, cText) end if self.ClickToChatButton then @@ -809,7 +809,7 @@ function Chat:PlayerChatted(...) end if - PlayersService.ClassicChat + Players.ClassicChat and (not (string.sub(message, 1, 3) == "/e " or string.sub( message, 1, @@ -898,7 +898,7 @@ function Chat:Initialize() Chat:PlayerChatted(...) end - self.EventListener = PlayersService.PlayerChatted:connect(chatted) + self.EventListener = Players.PlayerChatted:connect(chatted) self.MessageThread = coroutine.create(function() end) coroutine.resume(self.MessageThread) @@ -908,9 +908,9 @@ function Chat:Initialize() -- Eww, everytime a player is added, you have to redo the connection -- Seems this is not automatic -- NOTE: PlayerAdded only fires on the server, hence ChildAdded is used here - PlayersService.ChildAdded:connect(function() + Players.ChildAdded:connect(function() Chat.EventListener:disconnect() - self.EventListener = PlayersService.PlayerChatted:connect(chatted) + self.EventListener = Players.PlayerChatted:connect(chatted) end) Spawn(function()