# Advanced Nodes

### Getting Started

### Examples

### Simulations

### Connections

### Advanced Nodes

### Nodes Properties

### Custom Variables

### Collaboration

### Accounts

### Unity Plugin (UP) & API

### Evolution

## Registers

Use Registers to alter the state of Nodes or influence the flow of Resources based on the computation of multiple inputs coming from either Nodes in the diagram or your own input during a diagram Step-by-Step Run.

Registers can be `passive`

or `interactive`

. Set their state in the Properties panel under Functional, by ticking “Interactive” ON or OFF.

By default, Registers are `passive`

.

`Passive`

Registers may gather input from multiple origin Nodes, compute them based on formulas, and influence the state of other Connections or Nodes within the diagram.

Each Register input State Connection is assigned a letter Formula. Use these identifiers as variables in the formula the Register needs to compute.

💡 Note above that when the diagram is running the Register displays the computed result, before the run, it displays *fx.*

**Formula**

For `passive`

Registers the Formula is used to input the function you want it to compute.

**Label**

Use the Label field to provide context for what the Register represents in your game.

**Limits**

Set a minimum or maximum value under/above which factors influencing a Register can further affect its value.

For example: If the flow of producing Coins in a game is influenced by several factors (inputted to a Register), and you’ve set the minimum limit of that Register to 10, no matter how the inputs evolve throughout a play session, the player will, by the end of it, have at least 10 Coins.

A Register becomes `interactive`

when the “Interactive” option is ticked in the Properties panel, under Functional.

After ticking the “Interactive” option Registers become editable.Use the upward and downward arrows to interact and change a Register’s value.

Note that you **cannot** interact with a Register during Batch Plays.

**Function**

Interactive Registers do not support Formulas.

Use a `minimum`

and/or a `maximum`

value under and/or over which the Register doesn’t allow changes.

Upon ticking on “Interactive”, two properties become available for `interactive`

Registers:

– sets the value the Register passes on upon running the diagram**Initial Value**sets a multiplier for each interaction with the Register**Step Value**–

In the example above, the interactive Register has a set initial value of 3, and a step value of 2, as shown in the screenshot below. With each interaction, the Register changes its value (in real-time, during the diagram Step-by-Step Run) with +/-2.

Tick “Show in Chart” (an option also available in the contextual menu at right-click) to plot the values taken by the Register at each Time Step when running the diagram.

In the example above we are multiplying the Target value. To obtain this, we used an `interactive`

Register with a Step Value equal to the Target’s value. In order to have an integer x multiplying factor, we used “+100%” as a Formula on the State Connection.

This results in the Target being multiplied by the number of Steps that the user interactively changes on the Register during execution.

💡 Note: for those looking for the deprecated m operator, this method generates the same effect. If you need to multiply functions on the Target, then the Origin needs to be a `passive`

Register with a formula identical to that of the Target.

`add(a,b)`

adds the values of a and b`subtract(a,b)`

subtracts b from a`multiply(a,b)`

multiplies the values of a and b`divide(a,b)`

divides a by the value of b

`square(a)`

returns the square value of a (a*a)`cube(a)`

returns the cubic value of a (a*a*a)`sqrt(a)`

returns the square root of a`cbrt(a)`

returns the cubic root of a`pow(a,b)`

returns the value of a raised to the power of b

In the example below, we’re using Registers to keep track of certain values occurances.

On the left, a random number of Resources (D6 – between 1 and 6) are being produced and stored into the Pools. Each Step, the Register checks if the number of Resources stored in either of the two Pools is higher than 2, sums the values up, and activates the Source to its right if the sum is >0.

On the right, we use the same model to count when the Pools *simultaneously* contain a number of Resources above 2. The formula on the Register uses multiplication instead of addition to achieve this.

The Drains have the role of resetting the Pools values.

If you’re trying to model complex `if statements`

, you can use Registers to calculate conditions. You can find an example for both context and solution, in the article on how to emulate the Artificial Player legacy component, with machinations.io Nodes and Connections.

🧙 For more examples on using math.js functions with Registers, try out the** **public** **diagram below.

This model represents a simplistic leveling up system.

- The Register “Gained XP” computes XP received by the player based on Enemies killed and XP per kill.
- The Register “Level up cost” computes the cost of leveling up based on player Level and a “variable” that you can manually tweak during Play by clicking on the arrows of the Register (starting value: 100)