User Tools

Site Tools


Variable Examples

Variable Actions

Every Rocrail object which can trigger actions can also modify variable values.
The possible commands are listed in the Action Commands table.

Actions triggered by Variables

As many other objects in Rocrail variables can also trigger actions.
The status field is used to check if the variable has a certain value.
The possible operators are listed in the Status and Condition tabel.


Variables can be compared with numbers, other variables and Text objects in conditions.
The possible operators are listed in the Status and Condition tabel.

Random Variable Values

This example only shows how to play with a variable and its actions.

Variable v3 definition Action for loading v3 with a random number Action control v3 to trigger a text action Action for showing the value of v3 in tx2

A: Define the variable

The definition of variable v3 is very simple and needs only a range, min/max, in which a random number should be generated.
In this case between 5 and 15.

B: The random action

This action will load a random number in variable v3 regarding the min/max range.

C: An action control for the variable

An action control defined for variable v3 which will be activated if v3 becomes the random value of 12.

D: A text value action

This action will show the value of variable v3 in text object tx2.

Play virtual

  1. Add the action defined in step B to for example a sensor object with status on.
  2. Click as long on the sensor until v3 becomes 12. Some trace lines:
    • 15:09:20 variable [v3] cmd=[random] new random value=12
    • 15:09:18 variable [v3] cmd=[random] new random value=13
    • 15:09:16 variable [v3] cmd=[random] new random value=5
    • 15:09:13 variable [v3] cmd=[random] new random value=11
  3. The action tx2Value, shown in D, will be executed and the text object tx2 will show the value of v3. Server trace:
    • variable [v3] cmd=[random] new random value=12
    • Action tx2Value [tx-tx2:value]
    • Action execution tx2Value [tx-tx2:value]
    • setting text [tx2] to [value] lcid=[]
    • text event [-][#v3]
    • broadcast text [12]
variable/usecases-en.txt · Last modified: 2018/11/12 08:56 by