Flower Trail

Introduction

Leave a trail of flowers everywhere you go.

A flower trail

Step 1

We want to place flowers while walking so use an on travelled event for walk.

def on_travelled():
    pass
player.on_travelled(WALK, on_travelled)

Step 2

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():
    # @highlight
    blocks.place(YELLOW_FLOWER, pos(0, 0, 0))
player.on_travelled(WALK, on_travelled)

Step 3

Let’s have more flowers! Place an oxeye daisy while walking too.

def on_travelled():
    blocks.place(YELLOW_FLOWER, pos(0, 0, 0))
    # @highlight
    blocks.place(OXEYE_DAISY, pos(0, 0, 0))
player.on_travelled(WALK, on_travelled)

Step 4

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.

Step 5

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():
    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)

Step 6

Go back into Minecraft and see what your trail looks like now.

Step 7

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():
    # @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)

Step 8

Go to Minecraft now and make rows of flowers everywhere!