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
| Type | Name | Description |
|---|---|---|
any | input | Value to be inspected |
bool | show_hidden | Determines inspection depth: • When true - includes hidden elements such as metatables in the output• When false - displays only visible table contents |
int | depth_limit | Maximum nesting depth to display (0 = unlimited) |
Returns
| Type | Name | Description |
|---|---|---|
string | result | Formatted string representation of the value |
Examples
--Inspect simple table
local t = {a = 1, b = 2, c = 3}
local output = engine.inspect(t)
engine.print(output)
--{
-- a: 1
-- b: 2
-- c: 3
--}--Inspect array
local arr = {10, 20, 30}
local output = engine.inspect(arr)
engine.print(output)
--{
-- 1: 10
-- 2: 20
-- 3: 30
--}--Inspect nested table
local data = {
name = "John",
address = {
city = "NYC",
zip = 10001
}
}
local output = engine.inspect(data)
engine.print(output)
--{
-- name: "John"
-- address: {
-- city: "NYC"
-- zip: 10001
-- }
--}--Inspect with 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 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...>