Dynamic Impulses: Difference between revisions

From Resonite Wiki
expand the page on how data variants work with dynamic impulses
added Async, added warning for triggers
Line 18: Line 18:


<!--T:6-->
<!--T:6-->
A '''trigger''' takes a slot to target, a tag, and optionally a value to use. Every receiver under the targeted slot with a matching tag and value's datatype will be triggered. If the trigger has no datatype the receiver must have no data type.
A '''trigger''' takes a slot to target, a tag, and optionally a value to use. Every receiver under the targeted slot with a matching tag and value's datatype will be triggered. If the trigger has no datatype the receiver must have no data type.  
 
'''Because triggers scan an ''entire'' hierarchy for any and all eligible receivers, using Root as a target or pulsing the triggers frequently is ill-advised.'''


<!--T:7-->
<!--T:7-->
Line 34: Line 36:
Importantly, this means that anything available in the context of the triggering impulse, such as the collider that a collision occurred with, is also available to the receivers. This also makes dynamic impulses instant. If there are several receivers, they run in order; they will never run simultaneously. An infinite loop of dynamic impulses will eventually cause the involved nodes to break.
Importantly, this means that anything available in the context of the triggering impulse, such as the collider that a collision occurred with, is also available to the receivers. This also makes dynamic impulses instant. If there are several receivers, they run in order; they will never run simultaneously. An infinite loop of dynamic impulses will eventually cause the involved nodes to break.


= ASync =
There are also [[ASync]] variants the Triggers and Receivers.
When an [[ASync Dynamic Impulse Trigger]] is pulsed, it awaits on ''each'' [[ASync Dynamic Impulse Receiver]] it finds, the order in which the receivers are pulse is a depth first search*,<!-- *Needs Confirmation -->only when this search is complete is the `Next` pulse output triggered.


TODO: What about ASync Dynamic Impulse Triggers and Recievers?
{{Stub}}
{{Stub}}

Revision as of 07:20, 3 February 2024


Dynamic impulses allow for impulses to travel to other ProtoFlux programs anywhere in the world, and allow for large, complex programs to be built out of simple pieces.

Dynamic Impulses also have button component variants that also have alt versions for sending data. These components can trigger ProtoFlux just like Dynamic Impulse Trigger ProtoFlux nodes can.

Usage

There are two main parts to dynamic impulses: triggers and receivers.

A receiver takes a string tag and for the with data variant outputs a value. The tag and type determines what it listens for. A dynamic impulse is triggered only with an impulse of the correct tag and datatype. If no type is specified, the receiver has to have no type. Only when those conditions are met an impulse will flow out of the node.

A trigger takes a slot to target, a tag, and optionally a value to use. Every receiver under the targeted slot with a matching tag and value's datatype will be triggered. If the trigger has no datatype the receiver must have no data type.

Because triggers scan an entire hierarchy for any and all eligible receivers, using Root as a target or pulsing the triggers frequently is ill-advised.

Optionally, dynamic impulses can also carry a single value or reference. ProtoFlux nodes that can do this are Dynamic Impulse Trigger With Data and Dynamic Impulse Receiver With Data. There are also component variants, like Button Dynamic Impulse Trigger With Reference and Button Dynamic Impulse Trigger With Value. The value is sent by the trigger and received by the receiver.

Specifics

Dynamic Impulse Trigger and Dynamic Impulse Receiver are used for dynamic impulses that do not include a value.

A dynamic impulse trigger sends the impulse it received to all matching receivers.

Importantly, this means that anything available in the context of the triggering impulse, such as the collider that a collision occurred with, is also available to the receivers. This also makes dynamic impulses instant. If there are several receivers, they run in order; they will never run simultaneously. An infinite loop of dynamic impulses will eventually cause the involved nodes to break.

ASync

There are also ASync variants the Triggers and Receivers.

When an ASync Dynamic Impulse Trigger is pulsed, it awaits on each ASync Dynamic Impulse Receiver it finds, the order in which the receivers are pulse is a depth first search*,only when this search is complete is the `Next` pulse output triggered.


This article or section is a Stub. You can help the Resonite Wiki by expanding it.