Dynamic variables allow you to read and write data by name. This makes it easy to manage data in large systems; every bit of data is clearly labeled, and you can break data into multiple spaces to keep your systems separate.=
When using Dynamic Variables there are some restrictions and limitations on naming both spaces and variables within those spaces.
Space and Variable Names cannot contain:
- Any symbols
- As defined by C#'s Char.IsSymbol
- Any Punctuation / Whitespace
- Except for period (.), underscore (_) and space ( ).
A dynamic variable can have any name, as long as it doesn't include symbols, punctuation or whitespace. (As defined by C#) Exceptions to this are the underscore, period and space, which are allowed. Optionally, the name can be prefixed by the name of a space, terminated by a /, to choose a specific variable space to use. This is useful to distinguish between unrelated systems that all use dynamic variables.
Some valid names include:
- Health -- no space defined, named Health
- World/Color -- named Color, in the World space
- MyCoolSystem/Score -- named Score, in the MyCoolSystem space
Dynamic variables can live anywhere in or under the slot containing a DynamicVariableSpace component.
So, a variable space on the world root can be used from anywhere, whilst a variable space on your avatar can be used from anything stored in your avatar.
The simplest way to use dynamic variables is to use the DynamicValueVariable<T> and DynamicReferenceVariable<T> components. These are for value (int, float, String, etc.) and reference (Slot, User, etc.) types, respectively.
These components store a value or reference directly. If two variable components have the same name, then they will have identical contents.
If you want to use an existing field or reference as the contents of a dynamic variable, you can use the DynamicField<T> or DynamicReference<T> components. Instead of storing something directly, they point at a field that contains a value or reference type, respectively.
(TODO: clarify value vs. reference types; I think this isn't fully correct)
When creating a dynamic variable component, you will be given a list of "common types". If the type you seek is not in that list, you will have to enter it by hand. See Complex Types in Components.
Creating, duplicating, or moving a dynamic variable requires Neos to bind that variable to its space. This usually takes a small amount of time, before which the dynamic variable can appear to be present, but not be readable or writable. Therefore, if you create a dynamic variable using the Create Dynamic Variable or Write Or Create Dynamic Variable LogiX node, or cause it to be duplicated using the Duplicate Slot LogiX node, or cause it to be moved using the Set Parent LogiX node, you may find it necessary to add an Updates Delay or Updates Delay With Value LogiX node afterwards in order to ensure the dynamic variables have been bound by the time you use them. A delay of 1 to 3 updates usually suffices.
This article or section is a Stub. You can help the Neos Wiki by expanding it.