Step 3

Coding the setBlocks function


For our first bit of code, let’s create three new variables. Call them “Length”, “Height”, and “Width”.

Feel free to set these to whatever you want, but remember, the total amount of blocks we create will be Length x Height x Width so be careful!

Lastly, add the setBlocks function and all six of its parameters.

Here, we add legnth/height/width to offset from our inial x,y,z. For example, y + Height means the original y coordinate + “Height” blocks more up. This gives us the proper dimensions for length, height and width.

Testing/Running the code


Now that we have that completed, let’s run the code.

If done correctly, we should see a cube of brick blocks spawn! If not, double check all of your code.

Now that we got this working, see what sorts of cool things you can do with this new function.

If you want a challenge, see if you can make a block hollow. To do this, you will need to use the air block, block id 0. If you can get this, you can almost create a house entirely with Python code!