Skip to main content

Module script

Module script 

Source
Expand description

Rust scripting. Scripts are ordinary Rust types compiled into a dynamic library next to the project and hot-reloaded by the host. Host and library must be built by the same toolchain from the same engine sources; AbiInfo is checked on load to catch a mismatch early.

Note: statics are duplicated across the library boundary, so scripts must talk to the engine only through Ctx (that is why logging goes through Ctx::log).

Structs§

AbiInfo
Everything that must be identical in the host and in a scripts library for sharing engine memory to be sound: compiler, engine sources, and the layout of the types scripts touch.
Ctx
What a script sees each call.
ScriptDef
Exported script factory used by crate::register_scripts!.
ScriptHost
Loaded native script factories. Instances created by this host keep the library loaded even if the host is dropped, so their callback vtables remain valid.
ScriptLib
Library registration payload; construct through crate::register_scripts!.
ScriptRuntime
Native script instance lifecycle and per-instance panic isolation. A panic disables only the affected instance until it is recreated or reloaded.
Time
Simulation time supplied to one script callback.

Enums§

Phase
Gameplay callback phase dispatched by ScriptRuntime.

Traits§

Script
Implement this (plus Default) and list the type in register_scripts!. Public fields are exposed in the editor by returning them from fields().

Functions§

short_name
Last segment of a type path (a::b::Spin becomes Spin); used by [register_scripts!].