atl::sys
Raw bindings to the loader's GDT imports (the "atl" import module), as in the C SDK's atl.h.
Functions
Section titled "Functions"pub fn log(ptr: *const u8, len: i32)Writes len bytes at ptr to the game log as info / warning / error.
pub fn warn(ptr: *const u8, len: i32)pub fn error(ptr: *const u8, len: i32)pub fn abort(ptr: *const u8, len: i32)Raises a Lua error with the message, trapping (disabling) the mod.
pub fn is_server() -> i321 when running on the server side, 0 on a client.
pub fn mod_id(out: *mut u8, cap: i32) -> i32Copies this mod's id into out (up to cap bytes) and returns its full length.
pub fn val_type(v: Handle) -> i32The Type of a value.
pub fn val_number(x: f64) -> HandleCreates a new Lua number.
pub fn val_string(ptr: *const u8, len: i32) -> HandleCreates a new Lua string from len bytes at ptr.
pub fn val_bool(b: i32) -> HandleCreates a new Lua boolean (nonzero is true).
pub fn val_table() -> HandleCreates a new empty Lua table.
pub fn val_to_number(v: Handle) -> f64Reads a value as a number: true is 1, anything not convertible is 0.
pub fn val_to_string(v: Handle, out: *mut u8, cap: i32) -> i32Copies tostring(v) into out (up to cap bytes) and returns its full length.
pub fn val_base64_encode(v: Handle, prefix: *const u8, len: i32) -> HandleReturns a new string prefix .. base64(v), or nil if v isn't a string.
pub fn val_base64_decode(v: Handle, prefix: *const u8, len: i32) -> HandleReverses val_base64_encode: the decoded bytes, or nil if v doesn't start with
prefix or isn't valid base64.
pub fn val_cobs_encode(v: Handle, prefix: *const u8, len: i32) -> HandleLike the base64 pair, but COBS-encoded: no zero bytes and ~0.4% larger.
pub fn val_cobs_decode(v: Handle, prefix: *const u8, len: i32) -> Handlepub fn val_to_bool(v: Handle) -> i32Lua truthiness of a value: 0 for nil and false, 1 otherwise.
pub fn val_dup(v: Handle) -> HandleReturns a new handle to the same value.
pub fn val_free(v: Handle)Releases a handle. Freeing nil is a no-op.
pub fn val_equals(a: Handle, b: Handle) -> i321 if two values are equal by Lua's ==, else 0.
pub fn val_global(path: *const u8, len: i32) -> HandleLooks up a dotted path from the Lua globals, e.g. "sm.vec3.new". Nil if any part is missing.
pub fn val_get(t: Handle, key: Handle) -> Handlet[key], as a new handle.
pub fn val_set(t: Handle, key: Handle, v: Handle)t[key] = v.
pub fn val_get_field(t: Handle, name: *const u8, len: i32) -> Handlet[name] with a string key, as a new handle.
pub fn val_set_field(t: Handle, name: *const u8, len: i32, v: Handle)t[name] = v with a string key.
pub fn val_get_number(t: Handle, name: *const u8, len: i32) -> f64t[name] read as a number, without allocating a handle.
pub fn val_set_number(t: Handle, name: *const u8, len: i32, x: f64)t[name] = x without allocating a handle.
pub fn val_get_index(t: Handle, i: i32) -> Handlet[i], as a new handle. Lua indices start at 1.
pub fn val_set_index(t: Handle, i: i32, v: Handle)t[i] = v.
pub fn val_len(v: Handle) -> i32The length operator #v.
pub fn val_next(t: Handle, key: Handle) -> HandleThe key after key in t (Lua's next), or nil at the end. Start with nil.
pub fn call_begin()Starts a new call by clearing the argument buffer.
pub fn arg_nil()Appends one argument to the current call.
pub fn arg_number(x: f64)pub fn arg_string(ptr: *const u8, len: i32)pub fn arg_bool(b: i32)pub fn arg_value(v: Handle)pub fn call(f: Handle) -> i32Calls a function with the buffered arguments. Returns the number of results, or -1 if it raised an error (see last_error).
pub fn call_method(obj: Handle, name: *const u8, len: i32) -> i32Calls obj:name(...) with the buffered arguments. Returns like call.
pub fn result(i: i32) -> HandleResult i (from 0) of the last call, as a new handle.
pub fn result_number(i: i32) -> f64Result i (from 0) of the last call, read as a number.
pub fn last_error(out: *mut u8, cap: i32) -> i32Copies the last failed call's error message into out and returns its full length.
pub fn val_callback(export_name: *const u8, len: i32) -> HandleWraps one of this module's exports as a Lua function. Calling it from Lua calls the export with (self, args) handles.
pub fn log_str(s: &str)Writes s to the game log as info.
pub fn warn_str(s: &str)Writes s to the game log as a warning.
pub fn error_str(s: &str)Writes s to the game log as an error.
pub fn abort_str(s: &str) -> !Raises a Lua error with the message, trapping (disabling) the mod.
Constants
Section titled "Constants"pub const NETWORK_PACKET_LIMIT: usize = 65437The largest single game network send in bytes, counting the method name, the data and the game's framing. A string payload costs its length + the method name's length + 14. The network also cuts strings at their first zero byte.
Type aliases
Section titled "Type aliases"pub type Handle = i32A handle to a Lua value held by the host. 0 is nil.