@workadventure/scripting-api-extra
Advanced tools
Comparing version
@@ -1,1 +0,1 @@ | ||
export declare const defaultAssetsUrl = "https://unpkg.com/@workadventure/scripting-api-extra@1.1.1/dist"; | ||
export declare const defaultAssetsUrl = "https://unpkg.com/@workadventure/scripting-api-extra@1.2.0/dist"; |
@@ -1,2 +0,2 @@ | ||
export const defaultAssetsUrl = "https://unpkg.com/@workadventure/scripting-api-extra@1.1.1/dist"; | ||
export const defaultAssetsUrl = "https://unpkg.com/@workadventure/scripting-api-extra@1.2.0/dist"; | ||
//# sourceMappingURL=default_assets_url.js.map |
@@ -1,2 +0,2 @@ | ||
import { getAllVariables } from "../VariablesExtra"; | ||
import { getVariables } from "../VariablesExtra"; | ||
import { getLayersMap } from "../LayersFlattener"; | ||
@@ -94,6 +94,2 @@ import { Properties } from "../Properties"; | ||
let inZone = false; | ||
const zoneName = properties.getString("zone"); | ||
if (!zoneName) { | ||
throw new Error('Missing "zone" property on doorstep layer "' + name + '"'); | ||
} | ||
const tag = properties.getString("tag"); | ||
@@ -151,3 +147,3 @@ let allowed = true; | ||
} | ||
WA.room.onEnterZone(zoneName, () => { | ||
WA.room.onEnterLayer(name).subscribe(() => { | ||
inZone = true; | ||
@@ -174,3 +170,3 @@ if (properties.getBoolean("autoOpen") && allowed) { | ||
}); | ||
WA.room.onLeaveZone(zoneName, () => { | ||
WA.room.onLeaveLayer(name).subscribe(() => { | ||
inZone = false; | ||
@@ -224,7 +220,6 @@ if (properties.getBoolean("autoClose")) { | ||
} | ||
function initBellLayer(bellVariable, properties) { | ||
function initBellLayer(bellVariable, properties, layerName) { | ||
let popup = undefined; | ||
const zoneName = properties.mustGetString("zone"); | ||
const bellPopupName = properties.getString("bellPopup"); | ||
WA.room.onEnterZone(zoneName, () => { | ||
WA.room.onEnterLayer(layerName).subscribe(() => { | ||
var _a; | ||
@@ -245,3 +240,3 @@ if (!bellPopupName) { | ||
}); | ||
WA.room.onLeaveZone(zoneName, () => { | ||
WA.room.onLeaveLayer(layerName).subscribe(() => { | ||
if (popup) { | ||
@@ -255,3 +250,3 @@ popup.close(); | ||
assetsUrl = assetsUrl !== null && assetsUrl !== void 0 ? assetsUrl : defaultAssetsUrl; | ||
const variables = await getAllVariables(); | ||
const variables = await getVariables(); | ||
layersMap = await getLayersMap(); | ||
@@ -282,3 +277,3 @@ for (const variable of variables.values()) { | ||
if (bellVariable) { | ||
initBellLayer(bellVariable, properties); | ||
initBellLayer(bellVariable, properties, layer.name); | ||
} | ||
@@ -285,0 +280,0 @@ } |
@@ -8,5 +8,5 @@ import { getLayersMap } from "../LayersFlattener"; | ||
const properties = new Properties(layer.properties); | ||
initVariableActionLayer(properties); | ||
initVariableActionLayer(properties, layer.name); | ||
} | ||
} | ||
//# sourceMappingURL=special_properties.js.map |
import type { Properties } from "../Properties"; | ||
export declare function initVariableActionLayer(properties: Properties): void; | ||
export declare function initVariableActionLayer(properties: Properties, layerName: string): void; |
@@ -1,8 +0,4 @@ | ||
export function initVariableActionLayer(properties) { | ||
export function initVariableActionLayer(properties, layerName) { | ||
const variableName = properties.getString("bindVariable"); | ||
if (variableName) { | ||
const zone = properties.getString("zone"); | ||
if (!zone) { | ||
throw new Error('A layer with a "bindVariable" property must ALSO have a "zone" property.'); | ||
} | ||
const enterValue = properties.get("enterValue"); | ||
@@ -12,6 +8,6 @@ const leaveValue = properties.get("leaveValue"); | ||
const tag = properties.getString("tag"); | ||
setupVariableActionLayer(variableName, zone, enterValue, leaveValue, triggerMessage, tag); | ||
setupVariableActionLayer(variableName, layerName, enterValue, leaveValue, triggerMessage, tag); | ||
} | ||
} | ||
function setupVariableActionLayer(variableName, zone, enterValue, leaveValue, triggerMessage, tag) { | ||
function setupVariableActionLayer(variableName, layerName, enterValue, leaveValue, triggerMessage, tag) { | ||
if (tag && !WA.player.tags.includes(tag)) { | ||
@@ -21,3 +17,3 @@ return; | ||
if (enterValue !== undefined) { | ||
WA.room.onEnterZone(zone, () => { | ||
WA.room.onEnterLayer(layerName).subscribe(() => { | ||
if (triggerMessage) { | ||
@@ -31,3 +27,3 @@ } | ||
if (leaveValue !== undefined) { | ||
WA.room.onLeaveZone(zone, () => { | ||
WA.room.onLeaveLayer(layerName).subscribe(() => { | ||
WA.state[variableName] = leaveValue; | ||
@@ -34,0 +30,0 @@ }); |
@@ -1,3 +0,2 @@ | ||
/// <reference types="@workadventure/iframe-api-typings" /> | ||
import "./style/style.scss"; | ||
export {}; |
import "./style/style.scss"; | ||
import App from "./Components/App.svelte"; | ||
(async () => { | ||
const map = await WA.room.getTiledMap(); | ||
const configurationLayer = map.layers.find((layer) => layer.name === "configuration"); | ||
if (configurationLayer === undefined) { | ||
throw new Error('Could not find a layer with the name "configuration" on the map'); | ||
} | ||
new App({ | ||
target: document.body, | ||
props: { | ||
configurationLayer: configurationLayer, | ||
}, | ||
}); | ||
})().catch((e) => { | ||
console.error(e); | ||
new App({ | ||
target: document.body, | ||
}); | ||
//# sourceMappingURL=index.js.map |
@@ -8,3 +8,4 @@ import { getLayersMap } from "../../LayersFlattener"; | ||
const dtmfPlayer = new DtmfPlayer(); | ||
WA.onInit().then(async () => { | ||
WA.onInit() | ||
.then(async () => { | ||
const layerName = window.location.hash.substr(1); | ||
@@ -40,3 +41,4 @@ if (!layerName) { | ||
initKeyBindings(); | ||
}); | ||
}) | ||
.catch((e) => console.error(e)); | ||
function initKeyBindings() { | ||
@@ -43,0 +45,0 @@ document.querySelectorAll("button").forEach((button) => { |
@@ -5,4 +5,6 @@ import { initDoors } from "./Features/doors"; | ||
import { initPropertiesTemplates } from "./Features/properties_templates"; | ||
import { initTutorial } from "./Features/tutorial"; | ||
export function bootstrapExtra() { | ||
return WA.onInit().then(() => { | ||
return WA.onInit() | ||
.then(() => { | ||
initDoors().catch((e) => console.error(e)); | ||
@@ -12,4 +14,6 @@ initSpecialProperties().catch((e) => console.error(e)); | ||
initPropertiesTemplates().catch((e) => console.error(e)); | ||
}); | ||
initTutorial().catch((e) => console.error(e)); | ||
}) | ||
.catch((e) => console.error(e)); | ||
} | ||
//# sourceMappingURL=init.js.map |
@@ -12,2 +12,2 @@ import type { ITiledMapObject } from "@workadventure/tiled-map-type-guard/dist"; | ||
} | ||
export declare function getAllVariables(): Promise<Map<string, VariableDescriptor>>; | ||
export declare function getVariables(layerFilter?: string, variablesFilter?: Array<string>): Promise<Map<string, VariableDescriptor>>; |
@@ -24,9 +24,9 @@ import { Properties } from "./Properties"; | ||
} | ||
export async function getAllVariables() { | ||
export async function getVariables(layerFilter, variablesFilter) { | ||
const map = await WA.room.getTiledMap(); | ||
const variables = new Map(); | ||
getAllVariablesRecursive(map.layers, variables); | ||
getAllVariablesRecursive(map.layers, variables, layerFilter, variablesFilter); | ||
return variables; | ||
} | ||
function getAllVariablesRecursive(layers, variables) { | ||
function getAllVariablesRecursive(layers, variables, layerFilter, variablesFilter) { | ||
for (const layer of layers) { | ||
@@ -36,2 +36,6 @@ if (layer.type === "objectgroup") { | ||
if (object.type === "variable") { | ||
if (!!layerFilter && layer.name !== layerFilter) | ||
continue; | ||
if (!!variablesFilter && !variablesFilter.includes(object.name)) | ||
continue; | ||
variables.set(object.name, new VariableDescriptor(object)); | ||
@@ -42,3 +46,3 @@ } | ||
else if (layer.type === "group") { | ||
getAllVariablesRecursive(layer.layers, variables); | ||
getAllVariablesRecursive(layer.layers, variables, layerFilter, variablesFilter); | ||
} | ||
@@ -45,0 +49,0 @@ } |
{ | ||
"name": "@workadventure/scripting-api-extra", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "A set of utility functions / features to improve WorkAdventure maps", | ||
@@ -63,3 +63,3 @@ "main": "dist/index.js", | ||
"@types/webpack-dev-server": "^4.1.0", | ||
"@workadventure/iframe-api-typings": "^1.4.14", | ||
"@workadventure/iframe-api-typings": "^1.7.2", | ||
"copy-webpack-plugin": "^9.0.1", | ||
@@ -66,0 +66,0 @@ "cross-env": "^7.0.3", |
@@ -34,3 +34,3 @@ # WorkAdventure Scripting API Extra features | ||
- [Bells](docs/bells.md) | ||
- [Generic action zones](docs/generic-action-zones.md) | ||
- [Generic action layers](docs/generic-action-layers.md) | ||
@@ -37,0 +37,0 @@ ### Functions |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
4768898
163%107
37.18%9363
86.48%9
50%