ProtoFlux:Field As Variable: Difference between revisions

From Resonite Wiki
m added link
overhaul
 
(2 intermediate revisions by one other user not shown)
Line 4: Line 4:
|Inputs=
|Inputs=
[
[
{"Name":"Field", "Type":"IValue"}
{"Name":"Field", "Type":"IValue`1"}
]
]
|Outputs=
|Outputs=
[
[
{"Name":"*", "Type":"Variable"}
{"Name":"*", "Type":"IVariable`2"}
]
]
|}}
|}}


The '''Field As Variable''' node transforms an [[Type:IValue|IValue]] of the given type into an [[Type:IVariable|IVariable]] that can then be written to with an [[ProtoFlux:Indirect Write|Indirect Write]] node.


Field As Variable takes an [[Type:IValue`1|IValue<T>]] that wraps any Generic value, and outputs a variable that wraps the value field provided into the input Field ([[Type:IValue`1|IValue<T>]]).  
Despite being called "Field As Variable", any IValue type will work as input. An example of an IValue that is not necessarily a [[Type:IField|Field]] is the [[Component:AuthorityTimeBase|AuthorityTimeBase]] component.


{{Template:How To Make Type Variables|Indirects}}
This node implements IVariable itself. This means that one may drag the output of this node into a normal [[ProtoFlux:Write|Write]] node and write to the given IValue. This is actually more performant than using an Indirect Write, as a normal write node does not check if the variable changes every time it is pulsed. However, The performance gain diminishes the more often the input IValue changes, being roughly equal if the IValue changes at every write call.


== Inputs ==
== Inputs ==


=== Field ([[Type:IValue`1|IValue<T>]] Generic)===
=== Field ([[Type:IValue`1|IValue<T>]])===


The [[Type:IValue`1|IValue<T>]] to put inside of the output * ([[Type:Variable|Variable]]).
The IValue of type T to transform into a variable.


== Outputs ==
== Outputs ==


=== * ([[Type:Variable|Variable]] Generic) ===
=== * ([[Type:IVariable`2|Variable]]) ===
A variable that wraps the inputted Field ([[Type:IValue`1|IValue<T>]]).
 
A variable created from the given <code>Field</code>.


== Examples ==
== Examples ==
<gallery widths=560px heights=240px>
File:ProtoFlux Example Field As Variable Writing.webp|The two methods of conditionally writing to an IValue reference (in this case, a [[Component:ValueField|ValueField]] value) using the Field As Variable node. The top method is much more performant if the conditional does not change often.
</gallery>


{{Stub}}
[[Category:ProtoFlux:Core]]

Latest revision as of 01:37, 14 August 2024

Field As Variable<T>
Field
*
Core

The Field As Variable node transforms an IValue of the given type into an IVariable that can then be written to with an Indirect Write node.

Despite being called "Field As Variable", any IValue type will work as input. An example of an IValue that is not necessarily a Field is the AuthorityTimeBase component.

This node implements IVariable itself. This means that one may drag the output of this node into a normal Write node and write to the given IValue. This is actually more performant than using an Indirect Write, as a normal write node does not check if the variable changes every time it is pulsed. However, The performance gain diminishes the more often the input IValue changes, being roughly equal if the IValue changes at every write call.

Inputs

Field (IValue<T>)

The IValue of type T to transform into a variable.

Outputs

* (Variable)

A variable created from the given Field.

Examples