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): booleanParameters
| Parameter | Type | Description |
|---|---|---|
subject | function | number | Lua function or reachable stack level. C functions are rejected by prototype readers. |
option | string | s changes the source; n changes the name. Only the first character is read. |
value | string | Replacement text. |
fields | table | name, 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
renamedErrors: In the option form, an option not beginning with s or n raises an error.
