Server Scripting
Server resources can be written in C#, JavaScript or Go. Native C++ modules are available for low-level extensions.
The complete server JS API reference is Server JavaScript API.
Resource Types
| Type | Runtime | Use |
|---|---|---|
csharp | Varion.SDK | Gamemode and gameplay logic |
js | Varion Node host | Server scripts and shared JS workflows |
go | Varion Go host | Server-side Go logic |
none | No server runtime | Client-only resource |
A JS resource does not need modules = [ "js-module" ]: the server starts the Node host for every resource with type = "js" and a non-empty main.
Events
Server resources can receive player events and emit events to clients. In JS the first argument to onClient is a Player proxy, not a numeric id.
varion.OnPlayerConnect += player => varion.Log($"connect {player.Id}");
player.Emit("chat:addMessage", "Welcome");varion.onClient('chat:message', (player, message) => {
player.emit('chat:addMessage', message);
});RPC
Use RPC for request/response flows.
varion.OnClientRpc("server:ping", (player, args) => new { pong = true });varion.onRpc('server:ping', async (player) => ({ pong: true }));Resources
Each resource has its own resource.toml. Resource startup order is controlled by the resources list in server.toml and by optional dependencies in resource.toml. The [config] table is read synchronously with varion.getResourceConfig() (no await).
For the complete list of varion methods, see Server JavaScript API.