Skip to main content

Raw packets & Child instances

Raw packets

client:send(name, params?)

FieldType
Signature(self: Client, name: string, params: {[string]: any}?) → string?
Returnsstring?nil on success
Common errorsErrors.DISCONNECTED
Asyncyes

Sends an arbitrary BSON packet by id. params becomes the envelope body.

client:on(event, callback)

FieldType
Signature(self: Client, event: string, callback: (any) → ()) → ()
Returnsnothing
Asyncno

Subscribe to lifecycle / packet events:

  • "connect" — fires once when status reaches MENU_READY or IN_WORLD
  • "disconnect" — fires once when status leaves the connected set
  • "p" — every inbound packet
  • "p:<ID>" — only packets with matching ID field
client:send("WCM", { msg = "hi" })

client:on("p:WCM", function(params) -- only that ID
print(params)
end)
client:on("p", function(params) -- every inbound packet
print(params)
end)

-- Useful one-shots
client:send("GAW", {}) -- Get Active Worlds
client:send("GRW", {}) -- Get Recent Worlds
client:on("p:GRW", function(params)
-- fires until the script stops
end)

Child instances

Each is reachable via the client or a corresponding getX() global:

client:inventory() -- or getInventory()
client:world() -- or getWorld()
client:console() -- or getConsole()
client:logger() -- or getLogs()
client:scripting() -- or getScripting()

client:world()

FieldType
Signature(self: Client) → World
ReturnsWorld — current world handle, or nil when no world snapshot is loaded
Asyncyes

client:inventory()

FieldType
Signature(self: Client) → Inventory
ReturnsInventory — snapshot of the bot's inventory at capture time
Asyncyes

client:console()

FieldType
Signature(self: Client) → Console
ReturnsConsole — per-runtime console buffer (timestamped entries)
Asyncno

client:logger()

FieldType
Signature(self: Client) → Logger
ReturnsLogger — flat string-array view of the same buffer
Asyncno

client:scripting()

FieldType
Signature(self: Client) → Scripting
ReturnsScripting — per-bot script engine handle
Asyncno