Guides
Room Plugins
Extend gameplay logic with Rust or WASM plugins.
Room Plugins
Room plugins are where your game rules live.
Use plugins when you want custom room behavior such as:
- movement simulation
- combat resolution
- inventory updates
- game-specific events/messages
Two plugin modes
1) Rust plugin (compile-time)
Best when:
- you control server build/deploy
- you want native Rust performance and direct code integration
2) WASM plugin (runtime-loaded)
Best when:
- you want to ship new room logic without rebuilding data-plane image
- you want a stable host/plugin boundary
Configured through NEXIS_WASM_ROOM_PLUGINS.
Rust plugin authors can use the helper crate published on crates.io:
[dependencies]
nexis_wasm_plugin = "0.1.5"
serde_json = "1"Message contract inside plugins
Room message payload in plugin on_message:
{
"type": "player.move",
"data": { "x": 10, "y": 4, "seq": 18 }
}This means your plugin can define custom gameplay types freely (player.move, shoot, chat.send, etc.).
Minimal plugin logic pattern
- Read
input.type. - Parse
input.data. - Compute next authoritative state.
- Return updated state and optional emitted event.
References
- Tutorial: Create a Custom Room Plugin
- Example code:
examples/wasm-plugins/counter_rust_plugin
Plugin Message Path
Typed Plugin I/O
function (: ): {
if (. === 'inc') {
return {
: { : 1 },
: { : 'counter.updated', : { : 1 } },
};
}
return { : {} };
}