0% found this document useful (0 votes)
4 views1 page

Binding Variables To Properties - WorkAdventure Documentation

This document provides guidance on building maps using Tiled for WorkAdventure, focusing on binding variables to properties for dynamic interactions. It explains how to use the Scripting API Extra to create reactive maps by referencing variables within properties and controlling visibility based on variable states. Additionally, it highlights the importance of using the correct syntax for variable binding to avoid issues with HTML character escaping.

Uploaded by

raziq.brown
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Binding Variables To Properties - WorkAdventure Documentation

This document provides guidance on building maps using Tiled for WorkAdventure, focusing on binding variables to properties for dynamic interactions. It explains how to use the Scripting API Extra to create reactive maps by referencing variables within properties and controlling visibility based on variable states. Additionally, it highlights the importance of using the correct syntax for variable binding to avoid issues with HTML character escaping.

Uploaded by

raziq.brown
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Map Building Admin User Developer Tutorials Login Get Started Search ctrl K

Megaphone
Build your Map with Tiled Extra Features Binding Variables to Properties
Context
Entity collections file format
Configuration
Build your Map with Tiled
Binding Variables to Properties About bindings

Publishing your map The special "visible" property

Upload your Map to Inverting a boolean variable


INFO
WorkAdventure
To use variables to properties binding, you need to import the "Scripting API Extra" script in your map
Host your Map with GitHub
Pages
In WorkAdventure maps, "variables" are used to share a state between players.
Self-Hosting your Map

About WorkAdventure maps Using the Scripting API Extra library, you can bind your variables values directly into properties on your map.

Entries and exits


In a property of your map, use the {{{ variableName }}} to refer to the name of a property.
Opening a website when walking
on the map Sample

Meeting rooms
Let's imagine you want to dynamically change the URL of a co-website based on a variable value. You can create a new variable named
Special zones "myWebsiteUrl" and bind it to the openWebsite property of your co-website layer.

Animations

Integrated websites

Camera

Writing text on a map

Chat zones

Extra Features

Adding doors

Bells / Knocking on a door

Map configuration screen

Binding Variables to Properties

Action Layers

Properties Reference

Troubleshooting

Invite People to your Map

The property referring to the variable

Context
You can use template properties in:

any property of any "tile" layer


any property of a dynamic "area" object

CAUTION

To use bindings with area objects, you must first set the "dynamic" property to true.

It should be noted that "dynamic" areas are accessible via the scripting API but are not editable in the (upcoming) map editor.

The Dynamic custom property

Configuration
Binding variables to properties can make your map reactive to variable changes, but you still need to find a way to modify the values of
variables. There are plenty of ways to do this, including:

Using the scripting API


Using auto-generated configuration screen
Using generic action layers

About bindings
Use {{{ variableName }}} to refer to a variable name.

Behind the scene the Mustache templating engine is used. This means you can use all the features of Mustache like conditional:

openWebsite: {{#enableWebsite}}https://example.com{{/enableWebsite}}

The website above will be displayed only if the enableWebsite variable is set to true .

CAUTION

Be sure to use {{{ variableName }}} for binding variable and NOT {{ variableName }} . The version with a double curly-
braces will work most of the time, but it escapes HTML characters (which is not needed in properties of a map) and this might
cause weird behaviours (like breaking URLs)

The special "visible" property


You can control the visibility of a layer with the visible custom property.

If this custom property is set, it will override the "Visible" property of the layer.

If you bind it to a variable, you can display or hide a layer based on the value of a variable.

Usage of the visible property

Inverting a boolean variable


In the example above, the holeInWall property is a boolean variable. If it is set to true , we want to hide the layer. So we are setting a
visible property on the layer. If we put visible: {{{ holeInWall }}} the layer would be visible when holeInWall is true . But
here, we want the opposite: the layer must be displayed when holeInWall variable is false . To do this, we can use Mustache's
"inverted sections" (delimited by {{^variable}}...{{/variable}} ). This section will be displayed if the variable is false or empty.

Therefore, {{^holeInWall}}1{{/holeInWall}} will return "1" when the value of holeInWall is false, and will be empty otherwise.

Edit this page

Previous Next
« Map configuration screen Action Layers »

Docs Need help ? Follow us

Map Building Book a demo Linkedin

Admin Discord Twitter


Developer GitHub Facebook

Copyright © 2024 workadventu.re - All Rights Reserved

You might also like