partey_workadventure/maps/tests/TriggerMessageApi/script.js

19 lines
457 B
JavaScript
Raw Normal View History

WA.onInit().then(() => {
2021-11-03 16:51:33 +01:00
let message;
2021-11-03 16:51:33 +01:00
WA.room.onEnterLayer("carpet").subscribe(() => {
message = WA.ui.displayActionMessage({
message:
"This is a test message. Press space to display a chat message. Walk out to hide the message.",
2021-11-03 16:51:33 +01:00
callback: () => {
WA.chat.sendChatMessage("Hello world!", "The bot");
},
});
2021-11-03 16:51:33 +01:00
});
2021-11-03 16:51:33 +01:00
WA.room.onLeaveLayer("carpet").subscribe(() => {
message && message.remove();
});
});