How code blocks work

Contents

    Learn how to use code blocks to build a program in Flock XR. This article steps you through useful tips for using the blocks.

    Block types

    There are two main types of block:

    • Container blocks: contain other blocks
    • Statement blocks: go inside container blocks and can be stacked

    Blocks that do both

    Some blocks are container blocks that can be stacked inside other container blocks. These are shown with an up-arrow in the bottom right corner.

    Click the arrow and the block will become stackable. Notice the notches in the blocks that make it stackable.

    Statement blocks need container blocks

    A statement block must be inside a container block or it will be disabled in the code area.

    Drag a block from the toolbox

    Always start a program with a container block first. This will usually be a start block.

    From Events drag the start block into the code area. It will jump into place.

    Drag a block inside a container block

    A yellow highlight will appear inside a container block to show you where the block will be dropped.

    From Scene drag the sky block inside the start block

    Drag blocks inside other blocks

    Rounded or hexagonal blocks can be dragged inside other blocks. These could be Boolean values (True or False), numbers, colours, materials, text, lists and many more! A yellow border will appear to let you know that you can drop your block.

    From Materials drag the list of colours block inside the sky block

    Add comments to blocks

    Comments are really useful reminders of what a stack of blocks was created for.

    Right click on the start block and choose add comment

    Click the post it icon to open the comment

    Type a comment

    Click the post it icon again to close the comment

    Collapse a stack of blocks

    As your program grows you will have lots of blocks in your code area. You can collapse a stack of blocks to tidy up your code area.

    Right click on the start block and choose Collapse block

    Right click on the start block again and choose Expand block to expand it

    Disable and enable blocks

    You might need to disable a block temporarily to help you with testing or to move something out of the way when you are building in the canvas.

    Right click on the start block and choose Disable block

    Right click on the start block again and choose Enable block

    Delete blocks

    To delete a block, drag it back into the toolbox or drag it to the bin in the bottom right corner.

    Drag one block from inside a stack of blocks

    When you drag a stack of blocks, all the blocks below come with it.

    To drag one block on its own, hold down CTRL on your keyboard and drag the single block. On a tablet you can right click and choose Detach. Cut and paste also works.

    Updated on December 18, 2025