A set of blocks are functions that can pause or resume their execution while maintaining their state. You can exit the chaining process at any time, and the next time you call this function, execution will continue from where you left off. These blocks can be paused to allow other functions to do some work. They can not only be started and stopped, but also paused and resumed

  • Execute the chain constantly - upon reaching the end, the chain will not finish its execution, but will independently go to the beginning and will be restarted an infinite number of times

This block is necessary to repeat the logical construction, since the blocks added to the workspace are executed once, at the moment the block or block construction is called. You can read more about the block execution order in the corresponding article

  • Execute without waiting - the execution of this block does not block the execution of the next block in the sequence chain
  • Wait until N is true - blocks execution of the chain while the condition inside it is true

As a condition, you can set any logical block

  • Wait for N seconds - after triggering, blocks the execution of the block chain for the specified number of seconds

This block is an almost complete replacement for the complex construction of blocks using a timer, the execution of which led to the execution of the following functions

  • Wait frame - this block is triggered when the next frame is rendered
  • Stop chain execution - the block stops the logic chain execution algorithm
  • Start the chain again - triggering this block causes the chain to start from the very beginning

Execution of sequential actions on an example

To understand how chains work, let’s create a small project

  • Place three objects on the scene: a cube, a cone and a pyramid. Make the objects static

  • Run the project in preview mode on the PC. Each block of logic is executed only after the previous one has been executed
  • Go to the Blockly logic editor and change all sequential actions to simultaneous:

  • Run the project in preview mode on the PC. All blocks of logic are executed simultaneously
  • Switch to scene editing mode on PC
  • Add a simple button below each object

  • Go to the Blockly logic editor and change back from simultaneous to sequential
  • Add the following logic:

  • Run the project in preview mode on the PC. Wait until the execution of successive actions is completed - all objects will change color
  • Click on the button below the cube. The cube will **move**along the y-axis until the button is released. To verify this, press the button again
  • Click on the button below the cone. The cone will be scaled along the given axis. Approach the pyramid and press the button below it - nothing happened, the cone continues to scale. This is because the sequential zoom action has not completed. To do this, press the button under the cone
  • Now press the button below the pyramid. The pyramid began to rotate around a given axis and the sequential action will end only after the button is released