Flower Trail
Introduction
Leave a trail of flowers everywhere you go.
Start walking
We want to place flowers while walking so use an on travelled event for walk.
def on_travelled_walk():
pass
player.on_travelled(WALK, on_travelled_walk)
Place a flower
Place a yellow flower at the player’s current position when walking.
The numbers (0, 0, 0)
mean the flower will be placed at your current position. So, every position you walk to gets a flower.
def on_travelled_walk():
# @highlight
blocks.place(YELLOW_FLOWER, pos(0, 0, 0))
player.on_travelled(WALK, on_travelled_walk)
Place another flower
Let’s have more flowers! Place an oxeye daisy while walking too.
def on_travelled_walk():
blocks.place(YELLOW_FLOWER, pos(0, 0, 0))
# @highlight
blocks.place(OXEYE_DAISY, pos(0, 0, 0))
player.on_travelled(WALK, on_travelled_walk)
Try it!
Go to Minecraft and start walking for a second or two. Turn around and look at your flower trail. If you walk backward, you can watch the flowers pop from the ground as you move.
One more flower
Now that’s very nice, but it would be fun to place a whole bouqeut while you walk! Place one more flower that you like.
def on_travelled_walk():
blocks.place(YELLOW_FLOWER, pos(0, 0, 0))
blocks.place(OXEYE_DAISY, pos(0, 0, 0))
# @highlight
blocks.place(POPPY, pos(0, 0, 0))
player.on_travelled(WALK, on_travelled_walk)
Try it again
Go back into Minecraft and see what your trail looks like now.
Plant rows of flowers
For the first flower that you place, change the first 0
in its position to 1
. For the third flower, change its first 0
for the position to -1
. Now you will place the flowers in rows!
def on_travelled_walk():
# @highlight
blocks.place(YELLOW_FLOWER, pos(1, 0, 0))
blocks.place(OXEYE_DAISY, pos(0, 0, 0))
# @highlight
blocks.place(POPPY, pos(-1, 0, 0))
player.on_travelled(WALK, on_travelled_walk)
Make your trail!
Go to Minecraft now and make rows of flowers everywhere!