Features/Build & Create/Scripting API
codeMap Scripting

Code That Shapes Worlds.

WA.ui, WA.room, WA.player, WA.state— the scripting API from WorkAdventure. Control rooms, players, state, and UI from your map scripts.

API Pillars

Core modules for environment manipulation.

web_asset

WA.ui

Create UI elements, buttons, and modals within the world canvas. Open modal windows, add action bar buttons, and build custom interfaces.

WA.ui.openModal()WA.ui.actionBar.addButton()
meeting_room

WA.room

Control room properties, layer visibility, and spatial triggers. Hide/show layers, enter/leave zones, and manage the room state.

WA.room.onEnterZone()WA.room.hideLayer()
person_play

WA.player

Manage player position, avatars, and session data. Move players between maps, set custom avatars, and access user profile information.

WA.player.moveTo()WA.player.setPlayerBadge()
database

WA.state

Handle persistent room variables and cross-user synchronization. Store, retrieve, and share state across all players in a room.

WA.state.saveVariable()WA.state.onVariableChange()
script.ts
// Listen for zone entry
WA.room.onEnterZone('welcome-zone', () => {
// Open a welcome modal
WA.ui.openModal({
title: "Welcome!",
content: "<p>You've entered the BAWES Universe.</p>"
});

// Move player to a specific position
WA.player.moveTo(200, 300);
});

// Save state across sessions
WA.state.saveVariable('visitor_count', 42, {
public: true,
persist: true
});
cable

Scripting Events

Reactive patterns to build living environments.

login
onEnter

Fires when a player enters a map or a specific zone. Great for welcome messages, tutorials, and entrance effects.

logout
onLeave

Trigger cleanup actions when a user departs a defined spatial area.

bolt
onEvent

The generic listener for custom inter-script messaging. Send targeted events between scripts.

Persistent Variables

Store and synchronize state across all players in a room. Variables persist between sessions and can be public or private.

state.ts
// Save a public variable
WA.state.saveVariable('score', 100, {
public: true,
persist: true
});

// Listen for changes
WA.state.onVariableChange('score')
.subscribe((newValue) => {
console.log('Score:', newValue);
});

Key Features

  • check_circleCross-user synchronization — everyone sees the same state
  • check_circlePersistent variables survive room reloads
  • check_circlePublic or scoped visibility controls
  • check_circleReal-time subscriptions to value changes