new Trigger()
- Source:
Members
eventNames
Events we're able to receive and call handlers for.
- Source:
Methods
CallEvent(event, data)
This function executes the actions bound to the events.
It's either called directlty from other simulation scripts,
or from message listeners in this file
Parameters:
Name | Type | Description |
---|---|---|
event |
string | One of eventNames |
data |
Object | will be passed to the actions |
- Source:
CallTrigger()
Call the action method of a trigger with the given event Data.
By default, call the trigger even if it is currently disabled.
- Source:
DoAction()
Called by the trigger listeners to execute the actual action. Including sanity checks.
Intended for internal use, prefer CallEvent or CallTrigger.
- Source:
DoAfterDelay(time, action, eventData) → {number}
Execute a function after a certain delay.
Parameters:
Name | Type | Description |
---|---|---|
time |
number | Delay in milliseconds. |
action |
string | Name of the action function. |
eventData |
Object | Arbitrary object that will be passed to the action function. |
- Source:
Returns:
The ID of the timer, so it can be stopped later.
- Type
- number
DoRepeatedly(interval, action, eventData, startopt) → {number}
Execute a function each time a certain delay has passed.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
interval |
number | Interval in milleseconds between consecutive calls. | |
action |
string | Name of the action function. | |
eventData |
Object | Arbitrary object that will be passed to the action function. | |
start |
number |
<optional> |
Optional initial delay in milleseconds before starting the calls. If not given, interval will be used. |
- Source:
Returns:
the ID of the timer, so it can be stopped later.
- Type
- number
GetDifficulty()
Level of difficulty used by trigger scripts.
- Source:
RegisterTrigger(event, name, triggerData, customData)
Create a trigger listening on a specific event.
Parameters:
Name | Type | Description |
---|---|---|
event |
string | One of eventNames |
name |
string | Name of the trigger. If no action is specified in triggerData, the action will be the trigger name. |
triggerData |
Object | f.e. enabled or not, delay for timers, range for range triggers. |
customData |
Object | User-defined data that will be forwarded to the action. |
- Source:
Example
triggerData = { enabled: true, interval: 1000, delay: 500 }
General settings:
enabled = false * If the trigger is enabled by default.
action = name * The function (on Trigger) to call. Defaults to the trigger name.
Range trigger:
entities = [id1, id2] * Ids of the source
players = [1,2,3,...] * list of player ids
minRange = 0 * Minimum range for the query
maxRange = -1 * Maximum range for the query (-1 = no maximum)
requiredComponent = 0 * Required component id the entities will have