Component:ValueMultiplexer: Difference between revisions

From Resonite Wiki
No edit summary
m re-add generic components category
 
(5 intermediate revisions by 3 users not shown)
Line 3: Line 3:
|Name=Value Multiplexer`1
|Name=Value Multiplexer`1
}}
}}
{{stub}}
ValueMultiplexers allow to curate a list of values and [[Drive|drive]] a target with one of them.


They implement [[Type:IValue`1|IValue]] which means that a reference to them can be used to create a [[ProtoFlux:Source|Source]] node representing the currently indexed value. This enables using them like arrays when combined with a <code>Source</code> of the <code>Index</code> field.
The '''ValueMultiplexer''' component allow to curate a list of values and [[Drive|drive]] a target with one of them, much like a multiplexer.


== Usage ==
== Usage ==
{{Table ComponentFields
{{Table ComponentFields
|Target|{{RootFieldType|FieldDrive`1|T}}|TypeAdv0=true|A field which is driven with the currently selected
|Target|{{RootFieldType|FieldDrive`1|T}}|TypeAdv0=true|A field which is driven with the currently selected list value
|Index|Int|0-based index that determines which value of <code>Values</code> has been selected; values outside the range <code>[0;length-1]</code> are wrapped around internally.
|Index|Int|0-based index that determines which value of <code>Values</code> has been selected; values outside the range <code>[0;length-1]</code> are wrapped around internally.
|Values|{{RootFieldType|SyncFieldList`1|T}}|TypeAdv2=true|A list of values which can also individually be driven or written to
|Values|{{RootFieldType|SyncFieldList`1|T}}|TypeAdv2=true|A list of values which can also individually be driven or written to
|AllowWriteBack|Bool|Setting this to <code>true</code> redirects writes to <code>Target</code> or to a <code>Source</code> representing the selected value to the currently indexed list entry.
|AllowWriteBack|Bool|Setting this to <code>true</code> redirects writes from <code>Target</code> or from a <code>Source</code> representing the selected value to the currently indexed list entry.
}}
}}


== Behavior ==
== Behavior ==


The component behaves similar to a [[Component:ValueCopy|ValueCopy]] with the list entry indicated by <code>Index</code> as its <code>Source</code>.
The component behaves similar to a [[Component:ValueCopy|ValueCopy]] with the list entry indicated by <code>Index</code> as the value to output. Changes to <code>Index</code> or the list entries will affect <code>Target</code> whenever the drive is evaluated.
Changes to <code>Index</code> or the list entries will affect <code>Target</code> whenever the drive is evaluated.


On the other hand the <code>Source</code> of this component updates instantly.
In addition, the component implements the [[Type:IValue|IValue]] type. This allows the component to be [[ProtoFlux:Source|sourced]] by dragging out the component header with the ProtoFlux tip. This enables using the component like an array when sourcing the <code>Index</code> field as well. The source of this component will update instantly, as opposed to the drive being limited to once per frame.


== Examples ==
== Examples ==


[[File:ValueMultiplexer_ProtoFlux_1.png|thumb|center|500px|Array-like access from within ProtoFlux. Note the setting of <code>AllowWriteBack</code> and that you can only access a single value at a time!]]
<gallery widths=540px heights=280px>
[[File:ValueMultiplexer_ProtoFlux_Wrapping_Index.png|thumb|center|500px|A demonstration of what happens when <code>Index</code> is outside the usual range. (wraps around)]]
File:ValueMultiplexer_ProtoFlux_1.png|Array-like access from within ProtoFlux. Note the setting of <code>AllowWriteBack</code> and that you can only access a single value at a time!
File:ValueMultiplexer_ProtoFlux_Wrapping_Index.png|A demonstration of what happens when <code>Index</code> is outside the usual range. (wraps around)
</gallery>


== See Also ==
== See Also ==


[[Category:Components:Utility{{#translation:}}|Value Multiplexer`1]]
* [[Component:ReferenceMultiplexer]]
[[Category:Components{{#translation:}}|Value Multiplexer`1]]
* [[ProtoFlux:Multiplex]]
[[Category:Generic Components{{#translation:}}|Value Multiplexer`1]]
 
[[Category:ComponentStubs]]
[[Category:Components:Utility{{#translation:}}]]
[[Category:Generic Components{{#translation:}}]]
[[Category:Components{{#translation:}}]]

Latest revision as of 00:46, 8 November 2024

Component image 
Value Multiplexer`1 component as seen in the Scene Inspector


The ValueMultiplexer component allow to curate a list of values and drive a target with one of them, much like a multiplexer.

Usage

Fields
Name Type Description
persistent Bool Determines whether or not this item will be saved to the server.
UpdateOrder Int Controls the order in which this component is updated.
Enabled Bool Controls whether or not this component is enabled.
Target field drive of T A field which is driven with the currently selected list value
Index Int 0-based index that determines which value of Values has been selected; values outside the range [0;length-1] are wrapped around internally.
Values direct SyncFieldList`1<T> A list of values which can also individually be driven or written to
AllowWriteBack Bool Setting this to true redirects writes from Target or from a Source representing the selected value to the currently indexed list entry.

Behavior

The component behaves similar to a ValueCopy with the list entry indicated by Index as the value to output. Changes to Index or the list entries will affect Target whenever the drive is evaluated.

In addition, the component implements the IValue type. This allows the component to be sourced by dragging out the component header with the ProtoFlux tip. This enables using the component like an array when sourcing the Index field as well. The source of this component will update instantly, as opposed to the drive being limited to once per frame.

Examples

See Also