Vital.sandbox
Engine

engine.inspect

Shared

Returns a human-readable string representation of any value


Syntax

local result = engine.inspect(input, show_hidden = false, depth_limit = 0)

Parameters

TypeNameDescription
anyinputValue to be inspected
boolshow_hiddenDetermines inspection depth:
• When true - includes hidden elements such as metatables in the output
• When false - displays only visible table contents
intdepth_limitMaximum nesting depth to display (0 = unlimited)

Returns

TypeNameDescription
stringresultFormatted string representation of the value

Examples

Inspect a simple table
local t = {a = 1, b = 2, c = 3}
local output = engine.inspect(t)

engine.print(output)

--[[
Output:
{
    a: 1
    b: 2
    c: 3
}
]]
Inspect an array
local arr = {10, 20, 30}
local output = engine.inspect(arr)

engine.print(output)

--[[
Output:
{
    1: 10
    2: 20
    3: 30
}
]]
Inspect a nested table
local data = {
    name = "John",
    address = {
        city = "NYC",
        zip = 10001
    }
}
local output = engine.inspect(data)

engine.print(output)

--[[
Output:
{
    name: "John"
    address: {
        city: "NYC"
        zip: 10001
    }
}
]]
Inspect with a depth limit
local deep = {a = {b = {c = {d = {e = 5}}}}}
local output = engine.inspect(deep, false, 2)

engine.print(output) --Shows up to 2 levels, then {...}
Inspect primitive values
--Inspect string
local str = "hello world"
local output = engine.inspect(str)
engine.print(output) --'hello world'

--Inspect number
local num = 42
local output = engine.inspect(num)
engine.print(output) --42

--Inspect boolean
local bool = true
local output = engine.inspect(bool)
engine.print(output) --true

--Inspect nil
local value = nil
local output = engine.inspect(value)
engine.print(output) --nil

--Inspect function
local func = function() return 42 end
local output = engine.inspect(func)
engine.print(output) --'<function: 0x...>'

On this page