atl::callback
Callback slots: lets Rust closures stand in where the game expects a callback method name.
Functions
Section titled "Functions"pub fn current_self() -> HandleThe script instance whose code is running, which owns new callbacks, GUIs and triggers.
pub fn defer(f: impl FnOnce() + 'static)Queues f to run once the current call from the game has returned.
pub fn bind_callback<F, R>(mut f: F) -> (i32, String) where F: FnMut(&Value) -> R + 'static, R: IntoLua,Stores f in a free slot and returns its id and the name of a Lua method that calls it.
pub fn unbind_callback(id: i32)Frees a callback slot. Safe to call from inside that callback.
pub fn register_cleanup(hook: CleanupHook)Adds a hook that releases per-script resources (GUIs, triggers, ...).
pub fn release_owned_by(self_h: Handle, destroying: bool)Runs the cleanup hooks for a script instance and frees the callbacks it owns.
pub extern "C" fn atl_callback(id: i32, args: Handle) -> HandleThe export the loader calls when a bound callback fires: runs slot id with the
callback's arguments and returns its result handle.
Type aliases
Section titled "Type aliases"pub type Callback = Box<dyn FnMut(&Value) -> Value>A stored callback: receives the Lua arguments as one Value, returns a Value.
pub type CleanupHook = fn(self_h: Handle, destroying: bool)Called when a script instance is destroyed or its client/server side goes away.