Description
This script helps u debug stuff in Roblox by looking at the details of functions and tables. It goes deep into the code, checking up to 5 levels deep by default. When u run deepDebug, it logs info like function names, constants, upvalues, and the contents of tables. The logToRoblox function prints these details to Roblox’s output. Basically, it shows u what’s inside ur code so u can find problems easier.
Main Feature:
- Recursive Debugging
How to Use?
local function test()
local a = “Hello”
local b = {1, 2, {key = “value”}}
local function bar()
local c = “world”
end
end
deepDebug(test, 0, 5, logToRoblox)
MADE FOR DEVS!
local HttpService = game:GetService("HttpService")
local function deepDebug(value, depth, maxDepth, logFunction)
depth = depth or 0
maxDepth = maxDepth or 5
if depth > maxDepth then return end
local function log(msg)
logFunction(msg)
end
local valueType = typeof(value)
if valueType == "function" then
local info = debug.getinfo(value)
log(string.rep(" ", depth) .. "Function: " .. (info.name or "anonymous") .. " at " .. info.short_src .. ":" .. info.currentline)
local constants = debug.getconstants(value)
for i, v in pairs(constants) do
log(string.rep(" ", depth + 1) .. "Constant[" .. i .. "]: " .. tostring(v))
end
local upvalues = debug.getupvalues(value)
for i, v in pairs(upvalues) do
log(string.rep(" ", depth + 1) .. "Upvalue[" .. i .. "]: " .. tostring(v))
deepDebug(v, depth + 1, maxDepth, logFunction)
end
local protos = debug.getprotos(value)
for i, proto in pairs(protos) do
log(string.rep(" ", depth + 1) .. "Proto[" .. i .. "]: " .. tostring(proto))
deepDebug(proto, depth + 1, maxDepth, logFunction)
end
elseif valueType == "table" then
for k, v in pairs(value) do
log(string.rep(" ", depth) .. "Table Key: " .. tostring(k) .. ", Value: " .. tostring(v))
deepDebug(v, depth + 1, maxDepth, logFunction)
end
else
log(string.rep(" ", depth) .. tostring(value))
end
end
local function logToRoblox(msg)
print(msg)
end