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.
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()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()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()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()// Listen for zone entryWA.room.onEnterZone('welcome-zone', () => {// Open a welcome modalWA.ui.openModal({title: "Welcome!",content: "<p>You've entered the BAWES Universe.</p>"});
// Move player to a specific positionWA.player.moveTo(200, 300);});
// Save state across sessionsWA.state.saveVariable('visitor_count', 42, {public: true,persist: true});Scripting Events
Reactive patterns to build living environments.
onEnterFires when a player enters a map or a specific zone. Great for welcome messages, tutorials, and entrance effects.
onLeaveTrigger cleanup actions when a user departs a defined spatial area.
onEventThe 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.
// Save a public variableWA.state.saveVariable('score', 100, {public: true,persist: true});
// Listen for changesWA.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
Related
Inline Map Editor
Modify your universe in real-time with our browser-based editor.
Learn more arrow_forwardwidgetsArea Zones
Define interactions based on geographic proximity and room logic.
Learn more arrow_forwardmenu_bookFull Docs
Complete scripting documentation on GitHub.
Read docs open_in_new