ProtoFlux:Write Latch: Difference between revisions

From Resonite Wiki
added link to impulses
m fix types
 
(2 intermediate revisions by the same user not shown)
Line 5: Line 5:
|Inputs=
|Inputs=
[
[
{"Name":"Set", "Type":"Impulse"},
{"Name":"Set", "Type":"Call"},
{"Name":"Reset", "Type":"Impulse"},
{"Name":"Reset", "Type":"Call"},
{"Name":"SetValue", "Type":"Dummy"},
{"Name":"SetValue", "Type":"Dummy"},
{"Name":"ResetValue", "Type":"Dummy"}
{"Name":"ResetValue", "Type":"Dummy"}
Line 18: Line 18:
|Globals=
|Globals=
[
[
{"Name":"Variable", "Type":"Variable"}
{"Name":"Variable", "Type":"IVariable`2"}
]
]
|}}
|}}


Write latches take a Variable ([[Type:Variable|Variable]]) as a global input, and the Variable will determine what SetValue (Generic) and ResetValue (Generic) will take as a value. The set and reset value inputs will never take different types from each other.
Write latches take a Variable ([[Type:IVariable`2|Variable]]) as a global input, and the Variable will determine what SetValue (Generic) and ResetValue (Generic) will take as a value. The set and reset value inputs will never take different types from each other.


When it comes to the global Variable ([[Type:Variable|Variable]]), pulling a protoflux wire from a [[ProtoFlux:Source|Source Node]] or a [[ProtoFlux:Reference Source|Reference Source Node]] and dropping it onto the global field will mark the value that the source points to as the value that should be modified by this node upon impulse.
{{Template:Basic Writes Info|Write Latches}}


{{Template:Basic Writes Info|Write Latches}}
{{Template:Direct Writes Info|Write Latches}}


== Inputs ==
== Inputs ==
Line 32: Line 32:
=== Reset ([[Impulses|Call]]) ===  
=== Reset ([[Impulses|Call]]) ===  


Call this to set the value pointed to by Variable ([[Type:Variable|Variable]] Generic) to the ResetValue (Generic) input.
Call this to set the value pointed to by Variable ([[Type:IVariable`2|Variable]] Generic) to the ResetValue (Generic) input.


=== Set ([[Impulses|Call]]) ===  
=== Set ([[Impulses|Call]]) ===  


Call this to set the value pointed to by Variable ([[Type:Variable|Variable]] Generic) to the SetValue (Generic) input.
Call this to set the value pointed to by Variable ([[Type:IVariable`2|Variable]] Generic) to the SetValue (Generic) input.


=== SetValue (Generic) ===
=== SetValue (Generic) ===


[[:Category:Type|Value]] to write to the value pointed to by Variable ([[Type:Variable|Variable]] Generic) upon calling Set ([[Impulses|Call]])  
[[:Category:Type|Value]] to write to the value pointed to by Variable ([[Type:IVariable`2|Variable]] Generic) upon calling Set ([[Impulses|Call]])  


=== ResetValue (Generic) ===
=== ResetValue (Generic) ===


[[:Category:Type|Value]] to write to the value pointed to by Variable ([[Type:Variable|Variable]] Generic) upon calling Reset ([[Impulses|Call]])  
[[:Category:Type|Value]] to write to the value pointed to by Variable ([[Type:IVariable`2|Variable]] Generic) upon calling Reset ([[Impulses|Call]])  


== Outputs ==
== Outputs ==
Line 50: Line 50:
=== OnSet ([[Impulses|Continuation]]) ===
=== OnSet ([[Impulses|Continuation]]) ===


sends an impulse after SetValue ([[Impulses|Call]]) has been impulsed and the value pointed to by Variable ([[Type:Variable|Variable]] Generic) has been set to SetValue (Generic).
sends an impulse after SetValue ([[Impulses|Call]]) has been impulsed and the value pointed to by Variable ([[Type:IVariable`2|Variable]] Generic) has been set to SetValue (Generic).


=== OnReset ([[Impulses|Continuation]]) ===
=== OnReset ([[Impulses|Continuation]]) ===


sends an impulse after ResetValue ([[Impulses|Call]]) has been impulsed and the value pointed to by Variable ([[Type:Variable|Variable]] Generic) has been set to ResetValue (Generic).
sends an impulse after ResetValue ([[Impulses|Call]]) has been impulsed and the value pointed to by Variable ([[Type:IVariable`2|Variable]] Generic) has been set to ResetValue (Generic).


=== OnFail (Continuation) ===
=== OnFail (Continuation) ===


sends an impulse after either ResetValue ([[Impulses|Call]]) or SetValue ([[Impulses|Call]]) has been impulsed and the value wasn't able to be written due to a missing Variable ([[Type:Variable|Variable]] Generic) Value.
sends an impulse after either ResetValue ([[Impulses|Call]]) or SetValue ([[Impulses|Call]]) has been impulsed and the value wasn't able to be written due to a missing Variable ([[Type:IVariable`2|Variable]] Generic) Value.


== Globals ==
== Globals ==


=== Variable ([[Type:Variable|Variable]] Generic)===
=== Variable ([[Type:IVariable`2|Variable]] Generic)===


The value source/ref source to write to.
The value source/ref source to write to.


== Examples ==
== Examples ==
{{Stub}}
<gallery widths=480px heights=480px>
File:Protoflux_example_write_latch.webp|Example of a write latch node set up to write text to a data model store variable, set will set the text to "hello" and reset sets it back to "goodbye".
</gallery>


[[Category:ProtoFlux:Actions]]
[[Category:ProtoFlux:Actions]]

Latest revision as of 19:16, 9 February 2024

Write Latch
Set
OnSet
Reset
OnReset
SetValue
OnFail
ResetValue
Variable
null
Actions

Write latches take a Variable (Variable) as a global input, and the Variable will determine what SetValue (Generic) and ResetValue (Generic) will take as a value. The set and reset value inputs will never take different types from each other.

Write Latches are a way to change a specified value without driving it. Instead you can use Write Latches to change a value in a similar fashion to changing the value through the inspector. Using Write Latches helps with performance too, since the values provided to the node only evaluate for one game tick while the node is being impulsed vs a driver which evaluates every game tick. This can also be used to reduce the amount of times code is evaluated. If you have to search the entire root for your code to find a slot and then do an operation, using Write Latches with your operations will help with performance since you're only searching once and not every single game tick.

When it comes to Write Latches, you can drag any matching typed source onto the Variable field to set that as the variable target. When you want to write to a Local Variable Store, Data Model Variable Store, or a Store Variable Store, you can grab the Variable field on Write Latches nodes and then choose the one you want in your context menu. This can save considerable time spent trying to find the type you want in another node menu.

Inputs

Reset (Call)

Call this to set the value pointed to by Variable (Variable Generic) to the ResetValue (Generic) input.

Set (Call)

Call this to set the value pointed to by Variable (Variable Generic) to the SetValue (Generic) input.

SetValue (Generic)

Value to write to the value pointed to by Variable (Variable Generic) upon calling Set (Call)

ResetValue (Generic)

Value to write to the value pointed to by Variable (Variable Generic) upon calling Reset (Call)

Outputs

OnSet (Continuation)

sends an impulse after SetValue (Call) has been impulsed and the value pointed to by Variable (Variable Generic) has been set to SetValue (Generic).

OnReset (Continuation)

sends an impulse after ResetValue (Call) has been impulsed and the value pointed to by Variable (Variable Generic) has been set to ResetValue (Generic).

OnFail (Continuation)

sends an impulse after either ResetValue (Call) or SetValue (Call) has been impulsed and the value wasn't able to be written due to a missing Variable (Variable Generic) Value.

Globals

Variable (Variable Generic)

The value source/ref source to write to.

Examples