AcediaDocumentation

debug.setinfo

Updates a Lua prototype's source or name field.

Returns whether the write succeeded. Takes either an option letter with a replacement string, or a table of fields naming every slot to write at once.

debug.setinfo(subject: function | number, option: string, value: string): boolean
debug.setinfo(subject: function | number, fields: table): boolean

Parameters

ParameterTypeDescription
subjectfunction | numberLua function or reachable stack level. C functions are rejected by prototype readers.
optionstrings changes the source; n changes the name. Only the first character is read.
valuestringReplacement text.
fieldstablename, source and short_src string fields; source and short_src write the same slot. Non-string and unknown fields are ignored.

Example

local function subject() end
debug.setinfo(subject, { name = "renamed", source = "@custom" })
print(debug.info(subject, "n"))

Example output

renamed

Errors: In the option form, an option not beginning with s or n raises an error.

On this page