Beginner Coding with Blocks
Chapter
>
Level

Variables
String Variables

Objective

Pick up items, store it in a string variable, open the chest to place the variable in it’s own container and close them to complete the level.

Store the harvest in a bag and put it away. There is a "Pumpkin" you must collect and store it in its own bag by using variables.

Walk through the field and grab the pumpkin by walking over it. There is a variable named: bag1 that can be set with the set_variable code block. Drag and drop the set_variable code block from Variables menu in the toolbox and add bag1 as it’s variable.

Block Diagram

Then on the Text menu in the toolbox you can find string bubbles. The text inside these code blocks are called strings.

Block Diagram

Drag and drop string a bubble and add it to the set_variable code block.

Block Diagram

Add the string "Pumpkin" to the bubble on the set_variable code block, exactly as written (remember the capital P). This effectively puts the pumpkin in the bag allowing you to store it, or in coding terms, sets the string as the value for the variable.

Next you’ll be using the Open , Place and Close blocks from the from the Actions menu in the toolbox. Walk to the X mark and while facing the chest, use the Open code block to open the chest, use the Place code block and add to it the bag1 variable code block from the Variables menu. This will place the bag in the chest.

Block Diagram

Once the bag has been stored in the chest, use the Close code block to close the chest and complete the level.

Code book