-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from workadventure/docs
Adding documentation for doors and bells
- Loading branch information
Showing
28 changed files
with
626 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{.section-title.accent.text-primary} | ||
# About the extended features | ||
|
||
WorkAdventure features can be extended through the use of the [scripting API](https://workadventu.re/map-building/scripting). | ||
|
||
This means anyone can write "scripts" that can be imported in any map and that add new properties to WorkAdventure. | ||
If you are a developer, do not hesitate to have a look at the [scripting API](https://workadventu.re/map-building/scripting) | ||
and to create your own custom properties / features. | ||
|
||
The WorkAdventure team also provides its own scripts that add various features. We put those features | ||
in a common package we call [Scripting API Extra](https://github.com/workadventure/scripting-api-extra). | ||
|
||
In this section, you will find a list of these extended features. | ||
|
||
## Importing the "extended features" | ||
|
||
Because a script is hosting the extended features, you need to import that script explicitly into your map. | ||
|
||
You can do so by adding a "script" property at the top level of your map, pointing to the URL: | ||
`https://unpkg.com/@workadventure/scripting-api-extra@^1/dist/bundle.js` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{.section-title.accent.text-primary} | ||
# Bells / Knocking on a door | ||
|
||
{.alert.alert-info} | ||
**Important!** To use the "bells" feature, you need to [import the "Scripting API Extra" script in your map](about.md#importing-the-extended-features) | ||
|
||
Bells are usually used next to [doors](doors.md) (even if they can be used independently) | ||
|
||
You can: | ||
|
||
- decide if the bell will ring automatically or by pressing a button | ||
- decide the sound of the bell (or a knocking on the door sound if you prefer) | ||
- decide if the bell can be heard on all the map, or only at a given radius around the bell | ||
|
||
## The bell variable | ||
|
||
In order to create a bell, you need to create a ["variable"](https://workadventu.re/map-building/api-state.md) that will | ||
be used to share the fact the bell is ringing. | ||
The value of the variable has no importance, it is just used to propagate the event that the bell is ringing. | ||
|
||
In order to add a variable, you need to create a "Point" on any "object layer" in your map, in Tiled. | ||
|
||
Unlike with classical variables, the position of the variable object is important. The sound will be emitted from this point. | ||
|
||
- You can give this variable any name. | ||
- The "type" of the object MUST be "variable". | ||
- You MUST define a custom boolean property named `bell`. The "bell" checkbox must be checked. | ||
|
||
Then add 2 properties | ||
|
||
- `bellSound`: URL of the sound of the bell ringing (you can also use a knock-knock-knock sound if you have a door :) ) | ||
- `soundRadius` (optional): The radius at which one can hear the sound (expressed in pixels, the sound center being **the position of the variable**) | ||
|
||
The farther you are from the sound center, the less you will hear the sound. If you don't set any soundRadius, the whole | ||
map will hear the sound. | ||
|
||
The URL of the sound can be absolute or relative. If you choose a relative URL, it is is relative to the map. | ||
|
||
<figure class="figure"> | ||
<img class="figure-img img-fluid rounded" src="images/bell_variable.png" alt="" /> | ||
<figcaption class="figure-caption">The bell variable</figcaption> | ||
</figure> | ||
|
||
## The bell display layer | ||
|
||
Now, we need to define the position on the map from where the bell sound can be triggered. | ||
|
||
Add a tile layer in your map. | ||
|
||
On the layer add those properties: | ||
|
||
- `zone` (string): a unique identifier for your bell layer (the need to define this property will be removed in a future version) | ||
- `bellVariable`: (Compulsory) the name of the "bell" variable that will be triggered when someone walks on this layer | ||
|
||
With only those 2 properties, whenever a user walks into the layer, the bell will automatically ring. | ||
|
||
## Adding a bell button | ||
|
||
Of course, most of the time, you want the bell to be triggered by a manual user interaction (pressing the bell button). | ||
|
||
To add this button, you should create a "rectangle" object on any object layer in Tiled. The button will appear within this | ||
rectangle object on the map. | ||
|
||
Give this rectangle object any name. | ||
|
||
<figure class="figure"> | ||
<img class="figure-img img-fluid rounded" src="images/bell_popup.png" alt="" /> | ||
<figcaption class="figure-caption">The bell "popup" rectangle</figcaption> | ||
</figure> | ||
|
||
Now, on the bell layer, create 2 properties: | ||
|
||
- `bellPopup`: the name of a rectangle object on the object layer in the map that will display the "Ring" button to ring the bell. | ||
- `bellButtonText`: the text to display in the button to ring the bell. Defaults to "Ring" | ||
|
||
<figure class="figure"> | ||
<img class="figure-img img-fluid rounded" src="images/bell_layer.png" alt="" /> | ||
<figcaption class="figure-caption">Complete list of properties for the bell layer</figcaption> | ||
</figure> | ||
|
||
{.alert.alert-info} | ||
**Pro tip:** the `bellButtonText` can contain emojis. So you can use the "bell" emoji in the text: 🔔 |
Oops, something went wrong.