0% found this document useful (0 votes)
6 views

Map Editor API _ WorkAdventure Documentation

The document outlines the WorkAdventure APIs, specifically focusing on the Map Scripting and Map Editor APIs. It details how to detect when a user enters or leaves defined areas in the map editor, providing examples of how to subscribe to these events. Additionally, it includes information on retrieving a list of all areas created in the map editor with their properties.

Uploaded by

raziq.brown
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Map Editor API _ WorkAdventure Documentation

The document outlines the WorkAdventure APIs, specifically focusing on the Map Scripting and Map Editor APIs. It details how to detect when a user enters or leaves defined areas in the map editor, providing examples of how to subscribe to these events. Additionally, it includes information on retrieving a list of all areas created in the map editor with their properties.

Uploaded by

raziq.brown
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Map Building Admin User Developer Tutorials Login Get Started Search ctrl K

WorkAdventure APIs Map Scripting API Api Reference Map Editor API
Detecting when the user enters/leaves an area
Inbound API edited by the map editor

Map Scripting API Map Editor API Getting the list of all areas created in the map
editor
Variables
Currently, the map editor API provides a way to read the areas defined in the map editor and to detect when the user enters or leaves
Events
an area. It is "read-only". You cannot modify the map using this API.
Api Reference
We opted for a different approach to the event's detection of 'enter' and 'leave' zones when dealing with an area edited by the map
Camera
editor.
Chat

Controls

Event
Detecting when the user enters/leaves an area edited by the map
Map Editor API
editor
Metadata
WA.mapEditor.onEnter(name: string): Subscription
Navigation WA.mapEditor.onLeave(name: string): Subscription

Player
Listens to the position of the current user. The event is triggered when the user enters or leaves a given area.
Players

Room name: the name of the area defined in the map editor.

Sound
Example:
Start

State const myAreaEnterSubscriber = WA.mapEditor.area.onEnter("myAreaName").subscribe(() => {


WA.chat.sendChatMessage("Hello!", "Mr Robot");
UI
});
Deprecated Functions
const myAreaLeaveSubscriber = WA.mapEditor.area.onLeave("myAreaName").subscribe(() => {
Extended utility functions WA.chat.sendChatMessage("Goodbye!", "Mr Robot");
myAreaSubscriber.unsubscribe();
Scripting Internals
});
Using Typescript
// If you want to stop listening to the events at some point:
Map Storage API myAreaEnterSubscriber.unsubscribe();
myAreaLeaveSubscriber.unsubscribe();
Room API

Getting the list of all areas created in the map editor


WA.mapEditor.area.list(): MapEditorArea[]

Returns the list of all areas created in the map editor.

interface MapEditorArea {
name: string;
x: number;
y: number;
width: number;
height: number;
description: string|undefined;
searchable: boolean|undefined;
}

Example:

const areas = await WA.mapEditor.area.list();


for (const area of areas) {
console.log(`Area ${area.name} at (${area.x}, ${area.y}) with width ${area.width} and height ${area.height}
}

Edit this page

Previous Next
« Event Metadata »

Docs Need help ? Follow us

Map Building Book a demo Linkedin


Admin Discord Twitter
Developer GitHub Facebook

Copyright © 2024 workadventu.re - All Rights Reserved

You might also like