Skip to content

Latest commit

 

History

History
60 lines (38 loc) · 6.19 KB

variables-and-objects.md

File metadata and controls

60 lines (38 loc) · 6.19 KB

Variables and Objects

You encountered Object nodes briefly in the For Each guide. In this guide we will take a closer look at Object and its simpler relative Variable.

Variables

Variable nodes are used to store and read data to and from memory in Noodl. Let's start with a simple example: How to use the Variable node.

The Variable node takes a single input value and when you send a signal to the Set input it will store that input value and update its output. As you might have figured out from the graph above, all Variable nodes that share the same Name will also share the same data value. When one is updated all others will be updated as well. You can pick any Name for your Variable. Simply type it in the properties or pick a previously used name.

The example graph above let's you type your name in the Text Input node and when you click the button it will update the Variable node.

Sometimes you want to control when Variable nodes are updated. You can use the Fetch input signal to achieve this. If you have a connection to the Fetch input, the Variable node will not automatically update the output value. Instead it will wait until you send a signal to fetch the value of the Variable node. Try making this update in the example above. Now you need to click the text label for it to update after you have stored a new value in the variable My Name.

Check out the reference documentation for Variable for more details.

Objects

Object nodes work very much like the Variable nodes but they can contain many values. You can create and name any number of properties on an Object node and then use it just like you would use a Variable node. You simply edit the properties of the Object node and create and name new ones as you like.

Connect to the properties you specify and use the node with Set, Fetch and the other signals that are available on the Object node.

The Object node has a few more inputs and outputs to detect changes on individual properties etc. Take a look at the Object reference documentation for more details.

Another difference between Object and Variable nodes, is that the Object node identifier is called Id instead of Name as in the Variable node. Id is used in the same way though as the Name.

Local values

Sometimes you simply want to put a value into a Variable or Object node. To do this use the following nodes: String, Boolean, Number and Color. These nodes can be used as input to other nodes when you just want to provide a static value.

These value nodes only exist at this specific point in the graph, they don't have an Id or Name so you can't reference them somewhere else. In the example above the variable My Name will get the value Hello there when it receives the Set signal.