Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Excerpt |
---|
Triggers Process instances are themselves functions – so which you can just run them directly to make them process their tasksto, uhm..., run them... |
Syntax
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
// Preferred method (for code clarity): Pulse // retrieve "foo" then run it Processes("yourTriggerfoo")(objrunData, maxDurationignoreQueueSize); // retrieveExactly "yourTrigger"the viasame Pulse()as anddoing then run itthis: Processes("foo").run(runData, ignoreQueueSize); // Alternate method (for code brevity): yourTrigger(obj, maxDuration); // run a "yourTriggerfoo" via it's global function |
Parameters
Be sure to read important notes below to fully understand the persistence and possible side effects of using these parameters!
foo(runData, ignoreQueueSize);
// Exactly the same as:
foo.run(runData, ignoreQueueSize);
// ...all four methods do exactly the same thing, they are just different syntaxes. |
Parameters
Parameter | Type | Mandatory | Notes | Pulse Version |
---|---|---|---|---|
objrunData | Variant | Optionally pass in a value or an object (or anything else) and it will be passed through to tasks when they are processedthat will be exposed to Tasks, and some events, as the "runData" parameter. See Notes section below for additional information. Defaults to an empty object. | 0.1 | |
maxDurtionignoreQueueSize | NumberBoolean | Optionally define the maximum amount of time the trigger should process tasks for per game tick. Note: The duration will be limited to PULSE_GAME_LAGIf set to Defaults to | 0.1 |
Return
valuesA boolean returnvalue
indicates whether some tasks were deferred to a later game tick – are there some tasks left to be processed?Value | Type | Notes | Pulse Process Version | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
true | Boolean | Some tasks are deferred to a later game tick | 0.1 | |||||||||
false | Boolean | All tasks for this run have been processed.|||||||||||
<instance> | Process Instance | The process instance is returned, so you can chain more instance methods, eg:
| 0.1 |
Notes
Running a trigger directly via the trigger function has the exact same effect as running it via trigger.run().Each time a new trigger instance run is started, the parameters (obj, maxDuration) are stored so they can be passed in to each task being processed in that trigger run. For this reason, it's not advisable to put game objects (anything derived from Base object) in to the "obj" param as they might get destroyed before the task processing them is run. If you must pass in a game object, then just make sure you have decent Error Handling around any code that interacts with it.If another trigger run is started before the current one is finished, it's parameters will be queued up (in an array, so there can be multiple runs queued) while the in-progress run is completed to ensure the tasks of the current run get the expected parameters. When runData parameter is pushed in to a stack so that each run can be given its applicable runData. When the current run finishes, the current parameters are cleared down and the queued parameters restored ready for the new runits runData is removed from the stack and the next run starts.
If a trigger has more than PULSE_than Process.MAX_QUEUED_RUNS in QUEUE runs in its queue, warning messages will be shown , indicating that a bigger interval or some other corrective action is required by the developerto indicate that developer attention is likely required (basically the process instance is becoming overloaded). If you expect to be issuing multiple runs on an instance in short succession, for example because a game event is triggering it, set the ignoreQueueSize parameter to true
to avoid such warnings.
Div | ||
---|---|---|
| ||
AvailabilityRequires:
|