natiny.script.run

Lua
natiny.script.run(script, source) -> status

Compiles a resource and runs it in another script. Control does not come back until it returns.

Parameters

Name Type Description
script number The script to run in
source number The text to run, from natiny.resource.load or from_data

Returns

Value Description
natiny.script.OK Ran to the end
natiny.script.LOAD_ERROR Did not compile, or the resource holds nothing
natiny.script.RUN_ERROR Compiled, then raised an error

get_error holds the message for either failure.

Example

Lua
local natiny = require("natiny")

local source = natiny.resource.load("mods/weather/main.lua")
local status = natiny.script.run(mod, source)
natiny.resource.destroy(source)

if status ~= natiny.script.OK then
    print("weather mod: " .. natiny.script.get_error(mod))
end