Commands
Registers slash commands in the in-game console. Reached via ui.registerCommand().
commandName string Command name; a leading / is added automatically if omitted description string Shown alongside the command in /help output callback (string[]) => string? Called with the command's arguments; its return value (if a string) is printed to the console Registers a console command. Re-registering the same command name (case-insensitive) replaces the previous registration (a warning is logged) — including one registered by a different asset pack. Throws if callback isn’t a function, or if called outside an asset pack context.
ui.registerCommand("/hello", "Prints a greeting", (args) => { if args.length > 0 { return "Hello, \(args[0])!" } return "Hello!"})Typing /hello world in the console calls callback with ["world"] (the command name itself is not included) and prints Hello, world!.
Behavior
Section titled “Behavior”- Quoted substrings in console input are preserved as a single argument, e.g.
/mycommand "hello world"callscallbackwith["hello world"]. - Returning a string from
callbackprints it to the console; returning anything else (including nothing) prints nothing. - Exceptions thrown by
callbackare caught and shown in the console asError: <message>rather than crashing anything. - Commands can be invoked by an unambiguous unique prefix (e.g.
/helif no other command starts withhel); an ambiguous prefix lists the possible matches instead of running anything. - Built-in engine commands are matched before script commands, so a script command can’t override one of those — but it can override another asset pack’s script command of the same name.
- There’s no method to unregister a command, and no way to declare a fixed argument count/schema —
callbackreceives the raw argument strings and is responsible for parsing/validating them itself. Registrations don’t survive a map/session change; a command must be re-registered each time Main.rl runs.
© 2026 Giraffe Lab LLC. All rights reserved.