Hardware Reference
In-Depth Information
coordinates for the doormat that you wrote down earlier? Enter them here, so
that the program knows exactly where your doormat is:
if pos.x == 10 and pos.z == 12:
mc.postToChat("welcome home")
Time to see if your program works! By choosing Run Run Module from the editor
window, you can move around the Minecraft world. When your player stands on the
doormat, the program should say “welcome home”, like Figure 2-5. Cool!
FIGURE.2-5 Walking on the doormat displays a “welcome home” message.
Notice how in the if statement you used the == (double equals) symbol? A
common mistake here is to use an = symbol (single equals). Try that and see
what happens; you should see an error when you run your program. Python uses
a single equals sign ( = ) to mean “store the value on the right hand side of the
statement into the variable on the left hand side of the statement” like a = 3 .
Python uses == (double equals) to mean “compare the value on the right hand
side against the value on the left hand side, like if a == 3:
Make sure you get the indentation correct when you code your Welcome Home
Game. The code that is part of the while True loop is indented by one level.
The mc.postToChat() that belongs to the if statement is indented by two
levels. If you get the indentation wrong, your program will do the wrong thing.
Search WWH ::




Custom Search