natiny.script.fail
natiny.script.fail(script, message)
Reports, from inside a function you gave another script, that the call failed. The error is raised over there after your function returns.
Parameters
| Name | Type | Description |
|---|---|---|
script |
number |
The script the call came from - the one you gave the function to |
message |
string |
What went wrong; left out, script function failed |
Example
natiny.script.set(mod, "host.open_save", function(name)
local file = saves[name]
if not file then
natiny.script.fail(mod, "open_save: no such save")
return
end
return file.bytes
end)
-- in the mod
local ok, err = pcall(host.open_save, name)
Notes
- Each call clears the flag before it starts, so a failure reported and then returned from a nested call does not leak outwards.