In the last lesson, we use some code to place a block. That code was in a language called Python. It's an incredibly powerful language that is really easy to get started with.
To refresh your memory, here's the code we used in the last tutorial. Go ahead and hit the Run button below to place the block again.
The 2 lines you see are called "statements". Each of them accomplishes a very specific task. Let's break these 2 Python statements down:
from ctb import place
is called an import statement.
It's used to "import" additional functionality into the file. The details of
Python imports aren't important to us at the moment and will be covered in
future tutorials. The important thing to note is that this statement allows us
to use the place
function (we'll talk about what a function is shortly).place
function to place a block at
coordinates (0, 0, 0)
.Let's talk about what a function means. Think of a function as a machine: you give it some instructions and the machine performs some operations based on your instructions. The machine may even produce an output of some sort that you could use elsewhere. In future tutorials, we'll talk about how you can create your own functions.
To use the place
function, we give it "instructions" by using the format (or
"syntax" as it's formally called) place(0, 0, 0)
. Here, we're telling Python
to execute the place
function with the instructions (or "arguments" as it's
formally called) 0, 0, 0
, which are the coordinates we'd like to place the
block in.
At the end of the last tutorial, I challenged you to think about placing
multiple blocks in the blocks-pane. As you may have figured out, it's just a
matter of invoking the place
function multiple times. So something like this
is going to produce two blocks side-by-side:
This opens up a whole world of possibilities: you can create all sorts of shapes by just placing more blocks. As you place more blocks, you'll start to get a sense of how the coordinates work in this 3 dimensional world.
Exercise: try creating a bigger block of size 2x2x2 by combining 8 unit sized blocks.
© 2024 Abhin Chhabra | Sitemap