m fix links |
TheAutopilot (talk | contribs) added examples demonstrating a few individual aspects of dynamic impulses |
||
(9 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
See Also: [[Impulses]] | |||
<!--T:1--> | <!--T:1--> | ||
Line 4: | Line 5: | ||
<!--T:2--> | <!--T:2--> | ||
'''Dynamic impulses''' allow for [[ | '''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. | ||
<!--T:12--> | |||
Dynamic Impulses also have button component variants that also have alt versions for sending data. These components can trigger ProtoFlux just like [[ProtoFlux:Dynamic Impulse Trigger|Dynamic Impulse Trigger]] ProtoFlux nodes can. | |||
= Usage = <!--T:3--> | = Usage = <!--T:3--> | ||
Line 12: | Line 16: | ||
<!--T:5--> | <!--T:5--> | ||
A '''receiver''' takes a string tag. | 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. | ||
<!--T:6--> | <!--T:6--> | ||
A '''trigger''' takes a slot to target and a | 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. | ||
{{Note|Because triggers scan an entire hierarchy for any and all eligible receivers on every pulse: pulsing the triggers frequently is ill-advised|warning}} | |||
{{Note|The slot that receives the impulse (i.e. slot linked into `TargetHierarchy`) has to have its code packed at least once for it to be able to receive impulses.|information}} | |||
<!--T:7--> | <!--T:7--> | ||
Optionally, dynamic impulses can also carry a single value. | Optionally, dynamic impulses can also carry a single value or reference. ProtoFlux nodes that can do this are [[ProtoFlux:Dynamic Impulse Trigger With Data|Dynamic Impulse Trigger With Data]] and [[ProtoFlux:Dynamic Impulse Receiver With Data|Dynamic Impulse Receiver With Data]]. There are also component variants, like [[Component:ButtonDynamicImpulseTriggerWithReference|Button Dynamic Impulse Trigger With Reference]] and [[Component:ButtonDynamicImpulseTriggerWithValue|Button Dynamic Impulse Trigger With Value]]. The value is sent by the trigger and received by the receiver. | ||
= Specifics = <!--T:8--> | = Specifics = <!--T:8--> | ||
Line 30: | Line 36: | ||
<!--T:11--> | <!--T:11--> | ||
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 Triggers and Receivers. | |||
When an [[ProtoFlux:ASync Dynamic Impulse Trigger|ASync Dynamic Impulse Trigger]] is pulsed, it awaits on ''each'' [[ProtoFlux:ASync Dynamic Impulse Receiver|ASync Dynamic Impulse Receiver]] it finds. The order in which the receivers are pulsed is a depth first search, only when this search is complete and every ASync Reciever has finished execution (Also known as Awaiting) will the `Next` output be triggered. | |||
{{Note|Async receivers react to async triggers and non-async receivers react to non-async triggers. There is no ''cross-talk''.|information}} | |||
= Examples = | |||
== Tags == | |||
This is a demonstration how tags decide which receivers are triggered and that the receivers are fired one after another: | |||
<gallery widths=480px heights=240px> | |||
File:Protoflux_example_DynamicImpulse_Tags.webp|The trigger with tag "Tag A" reaches all impulse receivers with the matching tag "Tag A". The next matching receiver is only triggered after the current one has finished execution. (execution order currently based on hierarchy) | |||
</gallery> | |||
== Types == | |||
This example shows how tags are overloaded based on type: | |||
<gallery widths=480px heights=240px> | |||
File:Protoflux_example_DynamicImpulse_Types.webp|Only receivers of a type matching the triggerering node/component are triggered. Even subtypes cannot trigger their supertypes. (-> A string can't trigger an object receiver.) | |||
</gallery> | |||
== Target Hierarchy == | |||
This demonstrates how the target hierarchy is traversed: | |||
<gallery widths=480px heights=240px> | |||
File:Protoflux_example_DynamicImpulse_Hierarchy.webp|The first impulse trigger reaches both impulse receivers within the target "Parent" while the second trigger only reaches the impulse receiver within target "Child B". | |||
</gallery> | |||
== Values == | |||
An example on how values are transmitted: | |||
<gallery widths=480px heights=240px> | |||
File:Protoflux_example_DynamicImpulse_Value.webp|"Changing Value" is a 2 initially and evaluated once to be used as a payload for a dynamic impulse. The value is only available while the receiver's OnTriggered impulse is executed. (see variables "Value A" and "Value B") <br/>Changes to the trigger's input are not reflected. (Increments of "Changing Value" did not affect impulse's payload.) | |||
</gallery> | |||
== Sync vs. ASync == | |||
A quick example that shows that async triggers and receivers are separate from the normal variants. | |||
<gallery widths=480px heights=240px> | |||
File:Protoflux_example_DynamicImpulse_Sync_vs_Async.webp|Async triggers reach async receivers and sync triggers reach sync receivers. | |||
</gallery> | |||
{{Stub}} |
Latest revision as of 16:51, 1 December 2024
See Also: Impulses
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.
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 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 pulsed is a depth first search, only when this search is complete and every ASync Reciever has finished execution (Also known as Awaiting) will the `Next` output be triggered.
Examples
Tags
This is a demonstration how tags decide which receivers are triggered and that the receivers are fired one after another:
-
The trigger with tag "Tag A" reaches all impulse receivers with the matching tag "Tag A". The next matching receiver is only triggered after the current one has finished execution. (execution order currently based on hierarchy)
Types
This example shows how tags are overloaded based on type:
-
Only receivers of a type matching the triggerering node/component are triggered. Even subtypes cannot trigger their supertypes. (-> A string can't trigger an object receiver.)
Target Hierarchy
This demonstrates how the target hierarchy is traversed:
-
The first impulse trigger reaches both impulse receivers within the target "Parent" while the second trigger only reaches the impulse receiver within target "Child B".
Values
An example on how values are transmitted:
-
"Changing Value" is a 2 initially and evaluated once to be used as a payload for a dynamic impulse. The value is only available while the receiver's OnTriggered impulse is executed. (see variables "Value A" and "Value B")
Changes to the trigger's input are not reflected. (Increments of "Changing Value" did not affect impulse's payload.)
Sync vs. ASync
A quick example that shows that async triggers and receivers are separate from the normal variants.
-
Async triggers reach async receivers and sync triggers reach sync receivers.
This article or section is a Stub. You can help the Resonite Wiki by expanding it.