Repository navigation
Scripting Automation
Automation scripts drive running servers. They react to console output, send commands, and schedule lifecycle events (such as restarts).
Automation scripts share the same sandbox, Permissions Model, and meta declaration as Provider scripts, but they interact with a different set of APIs.
When an automation script is enabled in the UI, it is loaded into a dedicated LState. The engine executes the script once to allow it to register its event hooks (often placed inside an optional register() function).
After registration, the script goes idle. The engine fires the hooks when relevant events occur. All hook callbacks are serialized in a single goroutine to ensure safe execution in gopher-lua.
Use global on_* functions to register callbacks.
-
on_log(id, callback): Triggered for every console line emitted by the server with the givenid.-
Requires Permission:
console_read
-
Requires Permission:
-
on_start(id, callback): Triggered when the server with the givenidstarts up. -
on_stop(id, callback): Triggered when the server shuts down. -
on_join(id, callback): Triggered when a player joins the server. Powered by the internal player tracker (EventBus) - no console regex parsing required.-
Requires Permission:
player_manage
-
Requires Permission:
-
on_leave(id, callback): Triggered when a player leaves the server.-
Requires Permission:
player_manage
-
Requires Permission:
-
schedule(seconds, callback): Runs an action periodically on a timer.-
Requires Permission:
schedule
-
Requires Permission:
The server table provides commands to control server instances interactively.
-
server.send(id, command): Writes a command to the target server's standard input (stdin).-
Requires Permission:
console_write
-
Requires Permission:
-
server.start(id): Starts the server.-
Requires Permission:
server_control
-
Requires Permission:
-
server.stop(id): Stops the server.-
Requires Permission:
server_control
-
Requires Permission:
-
server.restart(id): Shuts down and restarts the server.-
Requires Permission:
server_control
-
Requires Permission:
-
server.logs(id): Fetches the recent console history of a server. Returns a table containing alinesarray.-
Requires Permission:
console_read
-
Requires Permission:
-
server.list(): Returns a list of all registered servers.-
Requires Permission:
server_query
-
Requires Permission:
-
server.info(id): Returns info for a single server, ornilif unknown.-
Requires Permission:
server_query
-
Requires Permission:
-
server.players(id): Returns a list of players currently online.-
Requires Permission:
player_manage
-
Requires Permission:
-
server.kick(id, name[, reason]): Kicks a player (server must be running).-
Requires Permission:
player_manage,console_write
-
Requires Permission:
-
server.ban(id, target[, reason]): Bans a player or IP (server must be stopped).-
Requires Permission:
player_manage
-
Requires Permission:
-
server.unban(id, target): Removes a ban (server must be stopped).-
Requires Permission:
player_manage
-
Requires Permission:
-
server.bans(id): Returns the current ban list.-
Requires Permission:
player_manage
-
Requires Permission:
You can write messages to the engine's automation log by calling log(...) or print(...). This does not require any special permissions.
- Back to the Scripting Hub