Registers

construct complex functions

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

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 Label. 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.

Properties

Label

For passive Registers the Label is used to input the formula you want to compute.

🧙♂ Registers support functions from the math.js library.

Interactive Registers

A Register becomes interactive when the "Interactive" option is ticked in the Properties panel, under Functional.

After ticking the "Interactive" option Registers become editable during Step-by-Step Runs. Use the upward and downward arrows to interact and change a Register's value.

Properties

Label

The Label for an interactive Register has a purely descriptive function. Use it to describe what the Register stands for.

Limits

Use a minimum and/or a maximum value under and/or over which the Register doesn't allow changes.

Value

Upon ticking on "Interactive", two properties become available for interactive Registers:

  • Initial Value - sets the value the Register passes on upon running the diagram

  • Step Value - sets a multiplier for each interaction with the Register

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

Show In Chart

Tick "Show in Chart" (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.

Examples

1. Multiplying target value

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 Label 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 run time.

💡 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.

2. Using math.js functions

Basic calculations

  1. add(a,b) adds the values of a and b

  2. subtract(a,b) subtracts b from a

  3. multiply(a,b) multiplies the values of a and b

  4. divide(a,b) divides a by the value of b

Exponential functions

  1. square(a) returns the square value of a (a*a)

  2. cube(a) returns the cubic value of a (a*a*a)

  3. sqrt(a) returns the square root of a

  4. cbrt(a) returns the cubic root of a

  5. pow(a,b) returns the value of a raised to the power of b

🧙♂ For more examples on using math.js functions with Registers, access the public diagram Framework: Register and math.js functions, or find it in File > New from Template > Framework: Register and math.js functions

3. If Statements

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.