Skip to main content

script_runtime_register_module

Function script_runtime_register_module 

Source
pub fn script_runtime_register_module(
    runtime: &mut ScriptRuntime,
    name: &str,
    source: &str,
) -> Result<(), String>
Expand description

Compiles a script source and returns any syntax error, without running it, so a tool can validate scripts ahead of time. Compilation checks syntax, not whether a called command exists, which is resolved when the script runs. Registers source as an importable module named name, so other scripts can import "name" as alias; and call its functions. This is how a game grows a library of its own reusable scripts alongside the bundled std/* modules.