The alarm block

Try itThings that talk to each other

Now for the sender. A block will send the message "alarm" when the hero steps on it.

A message in one script

To see a message work, here is a guard that sends one and listens for it too.

​
trigger "alarm"
​

Try it

  1. Press Play Play this script, under the little game.
  2. Click the little game, so the arrow keys work.
  3. Hold the right arrow key to walk the hero toward the guard.

The guard sees the hero and sends "alarm". Its own last rule hears the message, so it shouts and jumps.

RuleWhat it does
when I see the {Hero}Sends the message.
when "alarm"Hears the message, and acts.

Make the alarm block in your game

In your game, the sender is a block, not a guard.

  1. Press Open your game here, in the builder below, and go to level 2.
  2. Press the Behavior button Behavior, on the left of the builder, and click the Script brush.
  3. Click one block of your floor, a few blocks before the door. The Terrain script window opens.
  4. Press Code Code. Type these two lines.
when the {Hero} steps on me
  trigger "alarm"
  1. Press Save Save.

The block now has a little scroll on it while you build. That shows it has a script.

This makes a new game in your Lab and opens the builder right here. It is free.

This section ticks itself when you press Play Play this script in the code box.

Press Play in the code box to finish this section.