natiny.script.call_value
Lua
natiny.script.call_value(script, fn, ...) -> ok, ...
Calls a function and answers the way call does: true and the
results, or false and the message.
Parameters
| Name |
Type |
Description |
script |
number |
The script the function belongs to |
fn |
function or reference |
A function read with get, or a reference from make_function |
... |
any |
Arguments, at most natiny.script.MAX_ARGS of them |
Returns
| Type |
Description |
boolean |
true and then up to natiny.script.MAX_RESULTS values returned by the function; false and the message when fn is not a function, is no longer valid, or the call raised |
Example
Lua
local on_frame = natiny.script.get(mod, "on_frame")
natiny.backend.loop(function(dt)
if on_frame then
local ok, err = natiny.script.call_value(mod, on_frame, dt)
if not ok then
print("mod stopped: " .. err)
on_frame = nil
end
end
end)