Syntax of expressions in the blocks

To declare variables and set certain values ​​for them, the “Variable Initialization” block is used.

"Variable Initialization" block

For mathematical expressions — "Expression" block.

"Expression" block

Also, mathematical expressions, including those that change the values ​​of variables, can be used almost everywhere where you can specify a value.

Blocks and their properties that do not allow the use of mathematical expressions are described in the section "Common blocks".

All variables in the program are global, i.e. their values ​​can be used in any block in the program.

TRIK Studio language

The language used inside the blocks is based on Lua 5.3 and largely follows its syntax. Nevertheless, there are significant differences, so a full description of the language used in TRIK Studio is given here.

Examples of expressions

Declaration of several variables in one block "Expression":

The same using "Variables Initialization" blocks:

Proportional controller for driving along the line using two light sensors for the TRIK platform:

An example of using arrays to set the ports of the “Motors forward” block. An array is created with the name a, the port M3 is assigned to the zero element, the first is M1, then the contents of the first element of the array are changed to M4, then the resulting array is transferred to the “Ports” property of the “Motors forward” block: