atl/sys
import "atl/sys"Raw bindings to the loader's GDT imports (the "atl" import module), as in the C SDK's atl.h.
Constants
Section titled "Constants"const NetworkPacketLimit = 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.
Functions
Section titled "Functions"func Log(ptr unsafe.Pointer, len int32)Writes len bytes at ptr to the game log as info / warning / error.
func Warn(ptr unsafe.Pointer, len int32)func Error(ptr unsafe.Pointer, len int32)func Abort(ptr unsafe.Pointer, len int32)Raises a Lua error with the message, trapping (disabling) the mod.
func IsServer() int321 when running on the server side, 0 on a client.
func ModID(out unsafe.Pointer, cap int32) int32Copies this mod's id into out (up to cap bytes) and returns its full length; a result larger than cap means it was truncated.
func ValType(v Handle) int32The Lua type of a value.
func ValToNumber(v Handle) float64Reads a value as a number: true is 1, anything not convertible is 0.
func ValToString(v Handle, out unsafe.Pointer, cap int32) int32Copies tostring(v) into out (up to cap bytes) and returns its full length.
func ValToBool(v Handle) int32Lua truthiness of a value: 0 for nil and false, 1 otherwise.
func ValFree(v Handle)Releases a handle. Freeing nil is a no-op.
func ValEquals(a, b Handle) int321 if two values are equal by Lua's ==, else 0.
func ValSet(t, key, v Handle)t[key] = v.
func ValSetField(t Handle, name unsafe.Pointer, len int32, v Handle)t[name] = v with a string key.
func ValGetNumber(t Handle, name unsafe.Pointer, len int32) float64t[name] read as a number, without allocating a handle.
func ValSetNumber(t Handle, name unsafe.Pointer, len int32, x float64)t[name] = x without allocating a handle.
func ValSetIndex(t Handle, i int32, v Handle)t[i] = v.
func ValLen(v Handle) int32The length operator #v.
func CallBegin()Starts a new call by clearing the argument buffer.
func ArgNil()Append one argument to the current call.
func ArgNumber(x float64)func ArgString(ptr unsafe.Pointer, len int32)func ArgBool(b int32)func ArgValue(v Handle)func Call(fn Handle) int32Calls a function with the buffered arguments. Returns the number of results, or -1 if it raised an error (see LastError).
func CallMethod(obj Handle, name unsafe.Pointer, len int32) int32Calls obj:name(...) with the buffered arguments. Returns like Call.
func ResultNumber(i int32) float64Result i (from 0) of the last call, read as a number.
func LastError(out unsafe.Pointer, cap int32) int32Copies the last failed call's error message into out and returns its full length.
func Str(s string) unsafe.PointerPointer to the bytes of s, for the imports above.
func LogStr(s string)Writes s to the game log as info.
func WarnStr(s string)Writes s to the game log as a warning.
func ErrorStr(s string)Writes s to the game log as an error.
func AbortStr(s string)Raises a Lua error with the message, trapping (disabling) the mod.
Handle
Section titled "Handle"type Handle = int32A handle to a Lua value held by the host. Handles are owned: free them with ValFree when done. 0 is nil.
func ValNumber(x float64) HandleCreates a new Lua number.
func ValString(ptr unsafe.Pointer, len int32) HandleCreates a new Lua string from len bytes at ptr.
func ValBool(b int32) HandleCreates a new Lua boolean (nonzero is true).
func ValTable() HandleCreates a new empty Lua table.
func ValBase64Encode(v Handle, prefix unsafe.Pointer, len int32) HandleReturns a new string prefix .. base64(v), or nil if v isn't a string.
func ValBase64Decode(v Handle, prefix unsafe.Pointer, len int32) HandleReverses ValBase64Encode: returns the decoded bytes, or nil if v doesn't start with prefix or isn't valid base64.
func ValCobsEncode(v Handle, prefix unsafe.Pointer, len int32) HandleLike the base64 pair, but COBS-encoded: no zero bytes and ~0.4% larger. Use it for strings sent over the game's network.
func ValCobsDecode(v Handle, prefix unsafe.Pointer, len int32) Handlefunc ValDup(v Handle) HandleReturns a new handle to the same value.
func ValGlobal(path unsafe.Pointer, len int32) HandleLooks up a dotted path from the Lua globals, e.g. "sm.vec3.new". Returns nil if any part is missing.
func ValGet(t, key Handle) Handlet[key], as a new handle.
func ValGetField(t Handle, name unsafe.Pointer, len int32) Handlet[name] with a string key, as a new handle.
func ValGetIndex(t Handle, i int32) Handlet[i], as a new handle. Lua indices start at 1.
func ValNext(t, key Handle) HandleThe key after key in t (Lua's next), or nil at the end. Start with nil; read the value with ValGet.
func Result(i int32) HandleResult i (from 0) of the last call, as a new handle.
func ValCallback(exportName unsafe.Pointer, len int32) HandleWraps one of this module's exports as a Lua function. Calling it from Lua calls the export with (self, args) handles.