-
Notifications
You must be signed in to change notification settings - Fork 0
Self Registering Scripts
Aside of the other quite powerful ways to hook a script to a broadcast, this one here might very well be your preferred way to run scripts: Let them self-register with the broker!
You may put a #broker command in your script (normally on top but that's no requirement) to hook this script to an event.
Note
Using this feature requires a running broker! Best approach for this is, to leave the SCRIPTOR_BROKER_AUTOSTART macro from the Scriptor_Configuration file at its default value of true, so you will always have a broker running.
#broker <typename>[.property:value] <broadcast>To make a script self-register with the broker upon compile, just tell the compiler with this preprocessor command, how it shall register the script. Let's go through the details:
| Part | Example | Description |
|---|---|---|
#broker |
This is the self-registration command | |
<typename> |
Monster |
The sender of the broadcast. This can be a game object or a code class, Scriptor works with both and can analyze inheritance of both |
[.property:value] |
.race:Orc |
Put together, this is a broadcast-filter for Monster.race == "Orc" and the script will be triggered for Orcs only |
<broadcast> |
MonsterDied |
The title of a broadcast message to match. Wildcards are not allowed here, each script must be attached to a fully qualified broadcast title |
So in the example above you have just created a script that will run whenever an Orc dies!
Back to Repo ● Wiki Home
Copyright © coldrock.games
- Home
- Scriptor Contents
- Scriptor Configuration
- Notepad⁺⁺ Integration
- Create a Script
- $ Variables
- Call a GML Function
- Scriptor global functions
- #-Commands
- The Scriptor Broker
- Broker Events
- Self-Registering Scripts
- Registering Broker Events
- Scriptor Broker File Format
- Extending Scriptor
- var
- new
- goto
- gosub and return
- return (without gosub)
- call
- reset
- Loops
- Conditionals