WebSocket Events
Live event pushes for tracking game states
WebSocket
Connect to ws://localhost:3000/ws.
All messages are JSON text frames with the format:
{ "event": "EventName", "data": { ... } }The server only sends messages; the client does not send any.
Events
BotAdded
A new bot was spawned.
{
"event": "BotAdded",
"data": {
"bot_id": 1,
"username": "string"
}
}BotRemoved
A bot was stopped.
{
"event": "BotRemoved",
"data": { "bot_id": 1 }
}BotStatus
Bot connection status changed.
{
"event": "BotStatus",
"data": {
"bot_id": 1,
"status": "in_world"
}
}See BotStatus values below.
BotWorld
Bot entered or left a world. world_name is an empty string when leaving.
{
"event": "BotWorld",
"data": {
"bot_id": 1,
"world_name": "string"
}
}BotMove
Bot position updated.
{
"event": "BotMove",
"data": {
"bot_id": 1,
"x": 0.0,
"y": 0.0
}
}BotGems
Bot gem balance changed.
{
"event": "BotGems",
"data": {
"bot_id": 1,
"gems": 0
}
}BotPing
Bot ping updated. Fired when the value changes.
{
"event": "BotPing",
"data": {
"bot_id": 1,
"ping_ms": 0
}
}BotTrackInfo
Account info received on login.
{
"event": "BotTrackInfo",
"data": {
"bot_id": 1,
"level": 0,
"grow_id": 0,
"install_date": 0,
"global_playtime": 0,
"awesomeness": 0
}
}PlayerSpawn
A player appeared in the bot's world.
{
"event": "PlayerSpawn",
"data": {
"bot_id": 1,
"net_id": 0,
"name": "string",
"country": "us",
"x": 0.0,
"y": 0.0
}
}PlayerMove
A player moved.
{
"event": "PlayerMove",
"data": {
"bot_id": 1,
"net_id": 0,
"x": 0.0,
"y": 0.0
}
}PlayerLeave
A player left the bot's world.
{
"event": "PlayerLeave",
"data": {
"bot_id": 1,
"net_id": 0
}
}WorldLoaded
Full world data sent once when the bot enters a world.
{
"event": "WorldLoaded",
"data": {
"bot_id": 1,
"name": "string",
"width": 100,
"height": 60,
"tiles": [
{
"fg": 2,
"bg": 8,
"flags": 64,
"tile_type": { "type": "Basic" }
}
]
}
}tiles is a flat array of tile objects in row-major order. Each tile has:
| Field | Type | Description |
|---|---|---|
fg | u16 | Foreground item ID |
bg | u16 | Background item ID |
flags | u16 | Raw TileFlags bitmask (see below) |
tile_type | object | Tagged extra data (see below) |
TileFlags bitmask
| Bit | Value | Name |
|---|---|---|
| 0 | 0x0001 | HAS_EXTRA_DATA |
| 1 | 0x0002 | HAS_PARENT |
| 2 | 0x0004 | WAS_SPLICED |
| 3 | 0x0008 | WILL_SPAWN_SEEDS_TOO |
| 4 | 0x0010 | IS_SEEDLING |
| 5 | 0x0020 | FLIPPED_X |
| 6 | 0x0040 | IS_ON |
| 7 | 0x0080 | IS_OPEN_TO_PUBLIC |
| 8 | 0x0100 | BG_IS_ON |
| 9 | 0x0200 | FG_ALT_MODE |
| 10 | 0x0400 | IS_WET |
| 11 | 0x0800 | GLUED |
| 12 | 0x1000 | ON_FIRE |
| 13 | 0x2000 | PAINTED_RED |
| 14 | 0x4000 | PAINTED_GREEN |
| 15 | 0x8000 | PAINTED_BLUE |
tile_type variants (discriminated by "type" field)
| Type | Extra fields |
|---|---|
Basic | — |
Sign | text: string, flags: u8 |
Door | text: string, owner_uid: u32 |
Lock | settings: u8, owner_uid: u32, access_count: u32, access_uids: u32[], minimum_level: u8 |
Seed | time_passed: u32, item_on_tree: u8 |
VendingMachine | item_id: u32, price: i32 |
DisplayBlock | item_id: u32 |
Mannequin | text: string, clothing_1..10: u16/u32 |
Dice | symbol: u8 |
Forge | temperature: u32 |
CookingOven | temperature_level: u32, ingredients: [u32,u32][] |
StorageBlock | items: [u32,u32][] |
WeatherMachine | settings: u32 |
HearthMonitor | data: u32, player_name: string |
SilkWorm | name: string, age: u32, color: u32, … |
CountryFlag | country: string |
AudioRack | note: string, volume: u32 |
TesseractManipulator | gems: u32, next_update_ms: u32, item_id: u32, enabled: u32 |
| (others) | See source TileType enum in src/world.rs |
TileUpdate
A single tile was modified.
{
"event": "TileUpdate",
"data": {
"bot_id": 1,
"x": 0,
"y": 0,
"fg": 0,
"bg": 0
}
}ObjectsUpdate
Full set of dropped objects in the world.
{
"event": "ObjectsUpdate",
"data": {
"bot_id": 1,
"objects": [
{
"uid": 0,
"item_id": 0,
"x": 0.0,
"y": 0.0,
"count": 1
}
]
}
}InventoryUpdate
Bot inventory changed.
{
"event": "InventoryUpdate",
"data": {
"bot_id": 1,
"gems": 0,
"items": [
{
"item_id": 0,
"amount": 0,
"is_active": false,
"action_type": 0
}
]
}
}Console
A console message was received (game chat, script output, etc.).
{
"event": "Console",
"data": {
"bot_id": 1,
"message": "string"
}
}