debug
debug
function debug.debug()
Enters an interactive mode with the user, running each string that the user enters.
getfenv
function debug.getfenv(o: any)
-> table
Returns the environment of object o .
gethook
function debug.gethook(co?: thread)
-> hook: function
2. mask: string
3. count: integer
Returns the current hook settings of the thread.
getinfo
function debug.getinfo(thread: thread, f: integer|fun(...any):...unknown, what?: string|"L"|"S"|"f"|"l"...(+4))
-> debuginfo
Returns a table with information about a function.
what:
+> "n" -- `name` and `namewhat`
+> "S" -- `source`, `short_src`, `linedefined`, `lastlinedefined`, and `what`
+> "l" -- `currentline`
+> "t" -- `istailcall`
+> "u" -- `nups`, `nparams`, and `isvararg`
+> "f" -- `func`
+> "r" -- `ftransfer` and `ntransfer`
+> "L" -- `activelines`getlocal
function debug.getlocal(thread: thread, f: integer|fun(...any):...unknown, index: integer)
-> name: string
2. value: any
Returns the name and the value of the local variable with index local of the function at level f of the stack.
getmetatable
function debug.getmetatable(object: any)
-> metatable: table
Returns the metatable of the given value.
getregistry
function debug.getregistry()
-> table
Returns the registry table.
getupvalue
function debug.getupvalue(f: fun(...any):...unknown, up: integer)
-> name: string
2. value: any
Returns the name and the value of the upvalue with index up of the function.
getuservalue
function debug.getuservalue(u: userdata, n?: integer)
-> any
2. boolean
Returns the n-th user value associated to the userdata u plus a boolean, false if the userdata does not have that value.
setcstacklimit
function debug.setcstacklimit(limit: integer)
-> boolean|integer
Deprecated in Lua 5.4.2
Sets a new limit for the C stack. This limit controls how deeply nested calls can go in Lua, with the intent of avoiding a stack overflow.
In case of success, this function returns the old limit. In case of error, it returns false.
setfenv
function debug.setfenv(object: <T>, env: table)
-> object: <T>
Sets the environment of the given object to the given table .
sethook
function debug.sethook(thread: thread, hook: fun(...any):...unknown, mask: string|"c"|"l"|"r", count?: integer)
Sets the given function as a hook.
mask:
+> "c" -- Calls hook when Lua calls a function.
+> "r" -- Calls hook when Lua returns from a function.
+> "l" -- Calls hook when Lua enters a new line of code.setlocal
function debug.setlocal(thread: thread, level: integer, index: integer, value: any)
-> name: string
Assigns the value to the local variable with index local of the function at level of the stack.
setmetatable
function debug.setmetatable(value: <T>, meta?: table)
-> value: <T>
Sets the metatable for the given value to the given table (which can be nil).
setupvalue
function debug.setupvalue(f: fun(...any):...unknown, up: integer, value: any)
-> name: string
Assigns the value to the upvalue with index up of the function.
setuservalue
function debug.setuservalue(udata: userdata, value: any, n?: integer)
-> udata: userdata
Sets the given value as the n-th user value associated to the given udata. udata must be a full userdata.
traceback
function debug.traceback(thread: thread, message?: any, level?: integer)
-> message: string
Returns a string with a traceback of the call stack. The optional message string is appended at the beginning of the traceback.
upvalueid
function debug.upvalueid(f: fun(...any):...unknown, n: integer)
-> id: lightuserdata
Returns a unique identifier (as a light userdata) for the upvalue numbered n from the given function.
upvaluejoin
function debug.upvaluejoin(f1: fun(...any):...unknown, n1: integer, f2: fun(...any):...unknown, n2: integer)
Make the n1-th upvalue of the Lua closure f1 refer to the n2-th upvalue of the Lua closure f2.