added trigger message code

This commit is contained in:
jonny 2021-06-23 17:32:32 +02:00
parent 3cf0a9ee84
commit 5472d220ba
9 changed files with 267 additions and 99 deletions

View file

@ -1,40 +1,41 @@
///<reference path="../../front/src/iframe_api.ts" />
console.log('SCRIPT LAUNCHED');
//WA.sendChatMessage('Hi, my name is Poly and I repeat what you say!', 'Poly Parrot');
var isFirstTimeTuto = false;
var textFirstPopup = 'Hey ! This is how to open start a discussion with someone ! You can be 4 max in a booble';
var textSecondPopup = 'You can also use the chat to communicate ! ';
var targetObjectTutoBubble ='myPopup1';
var targetObjectTutoChat ='myPopup2';
var targetObjectTutoBubble = 'myPopup1';
var targetObjectTutoChat = 'myPopup2';
var popUpExplanation = undefined;
function launchTuto (){
WA.ui.openPopup(targetObjectTutoBubble, textFirstPopup, [
{
label: "Next",
className: "popUpElement",
callback: (popup) => {
popup.close();
function launchTuto() {
WA.ui.openPopup(targetObjectTutoBubble, textFirstPopup, [
{
label: "Next",
className: "popUpElement",
callback: (popup) => {
popup.close();
WA.ui.openPopup(targetObjectTutoChat, textSecondPopup, [
{
label: "Open Chat",
className: "popUpElement",
callback: (popup1) => {
WA.chat.sendChatMessage("Hey you can talk here too ! ", 'WA Guide');
popup1.close();
WA.controls.restorePlayerControls();
}
WA.ui.openPopup(targetObjectTutoChat, textSecondPopup, [
{
label: "Open Chat",
className: "popUpElement",
callback: (popup1) => {
WA.chat.sendChatMessage("Hey you can talk here too ! ", 'WA Guide');
popup1.close();
WA.controls.restorePlayerControls();
}
}
])
}
])
}
]);
WA.controls.disablePlayerControls();
}
]);
WA.controls.disablePlayerControls();
}
WA.chat.onChatMessage((message => {
console.log('CHAT MESSAGE RECEIVED BY SCRIPT');
WA.chat.sendChatMessage('Poly Parrot says: "'+message+'"', 'Poly Parrot');
WA.chat.sendChatMessage('Poly Parrot says: "' + message + '"', 'Poly Parrot');
}));
WA.room.onEnterZone('myTrigger', () => {
@ -50,11 +51,11 @@ WA.room.onEnterZone('notExist', () => {
WA.room.onEnterZone('popupZone', () => {
WA.ui.displayBubble();
if (!isFirstTimeTuto) {
if(!isFirstTimeTuto) {
isFirstTimeTuto = true;
launchTuto();
}
else popUpExplanation = WA.ui.openPopup(targetObjectTutoChat,'Do you want to review the explanation ? ', [
else popUpExplanation = WA.ui.openPopup(targetObjectTutoChat, 'Do you want to review the explanation ? ', [
{
label: "No",
className: "popUpElementReviewexplanation",
@ -74,6 +75,13 @@ WA.room.onEnterZone('popupZone', () => {
});
WA.room.onLeaveZone('popupZone', () => {
if (popUpExplanation !== undefined) popUpExplanation.close();
if(popUpExplanation !== undefined) popUpExplanation.close();
WA.ui.removeBubble();
})
const message = WA.ui.triggerMessage("testMessage", () => {
WA.chat.sendChatMessage("triggered", "triggerbot");
})
setTimeout(() => {
message.remove();
}, 5000)