Add WA.player.language in the API
This commit is contained in:
parent
77f8426788
commit
8286cdd41d
5 changed files with 31 additions and 2 deletions
|
@ -5,6 +5,7 @@ export const isGameStateEvent = new tg.IsInterface()
|
|||
roomId: tg.isString,
|
||||
mapUrl: tg.isString,
|
||||
nickname: tg.isString,
|
||||
language: tg.isUnion(tg.isString, tg.isUndefined),
|
||||
uuid: tg.isUnion(tg.isString, tg.isUndefined),
|
||||
startLayerName: tg.isUnion(tg.isString, tg.isNull),
|
||||
tags: tg.isArray(tg.isString),
|
||||
|
|
|
@ -13,6 +13,12 @@ export const setPlayerName = (name: string) => {
|
|||
playerName = name;
|
||||
};
|
||||
|
||||
let playerLanguage: string | undefined;
|
||||
|
||||
export const setPlayerLanguage = (language: string | undefined) => {
|
||||
playerLanguage = language;
|
||||
};
|
||||
|
||||
let tags: string[] | undefined;
|
||||
|
||||
export const setTags = (_tags: string[]) => {
|
||||
|
@ -61,6 +67,15 @@ export class WorkadventurePlayerCommands extends IframeApiContribution<Workadven
|
|||
return playerName;
|
||||
}
|
||||
|
||||
get language(): string {
|
||||
if (playerLanguage === undefined) {
|
||||
throw new Error(
|
||||
"Player language not initialized yet. You should call WA.player.language within a WA.onInit callback."
|
||||
);
|
||||
}
|
||||
return playerLanguage;
|
||||
}
|
||||
|
||||
get tags(): string[] {
|
||||
if (tags === undefined) {
|
||||
throw new Error("Tags not initialized yet. You should call WA.player.tags within a WA.onInit callback.");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue