Dateien nach "src" hochladen

This commit is contained in:
kai
2024-10-25 15:55:46 +02:00
parent df57cbd9ea
commit 9a516f55e9
2 changed files with 39 additions and 0 deletions

3
src/README.md Normal file
View File

@@ -0,0 +1,3 @@
# WorkAdventure Map Starter Kit - Src Folder
In this directory you can put your scripts and other source code files.

36
src/main.ts Normal file
View File

@@ -0,0 +1,36 @@
/// <reference types="@workadventure/iframe-api-typings" />
import { bootstrapExtra } from "@workadventure/scripting-api-extra";
console.log('Script started successfully');
let currentPopup: any = undefined;
// Waiting for the API to be ready
WA.onInit().then(() => {
console.log('Scripting API ready');
console.log('Player tags: ',WA.player.tags)
WA.room.area.onEnter('clock').subscribe(() => {
const today = new Date();
const time = today.getHours() + ":" + today.getMinutes();
currentPopup = WA.ui.openPopup("clockPopup", "It's " + time, []);
})
WA.room.area.onLeave('clock').subscribe(closePopup)
// The line below bootstraps the Scripting API Extra library that adds a number of advanced properties/features to WorkAdventure
bootstrapExtra().then(() => {
console.log('Scripting API Extra ready');
}).catch(e => console.error(e));
}).catch(e => console.error(e));
function closePopup(){
if (currentPopup !== undefined) {
currentPopup.close();
currentPopup = undefined;
}
}
export {};