Minecraft Pi_ Introduction to Python
You may have recognized what looks like an equation in the second line of code in the last step. This line creates a variable. A variable is a way to represent and store information. In the Python, we can set variables equal to numbers, strings (groups of letters and numbers) and functions (commands created from a series of other commands). Let's create a variable to store the player location.
pos = mc.player.getPos()
We can now access the x (horizontal), y (vertical) and z (horizontal) by using pos.x, pos.y and pos.z. Notice that there are two horizontals. This is why we call it a 3 dimensional space. One horizontal is for forward and back and the other is for left and right.
Let's use these new variables to teleport up into the air with a function. mc.player.setPos(pos.x, pos.y + 100, pos.z)
Save with Ctrl + S and then press F5 to run it.
YouTube video: https://youtu.be/GusOzNXNL5s