Wake everyone up

Try itThings that talk to each other

One message can have many listeners. An alarm that only opens a door is a waste of a good alarm.

A guard that hears the alarm

This guard sleeps until it hears "alarm". In this code box, a timer sends the message after 3 seconds, because there is no block to step on.

​
trigger "alarm"
​

Try it

Press Play Play this script and count to 3. The message goes out, and the guard wakes.

The guard's last rule does not care who sent the message. A block, a timer, another enemy: it is all the same to the listener.

Wake the enemies in your game

  1. Press Open your game here, in the builder below, and go to level 2.
  2. Place an enemy or two on the far side of the door.
  3. Press Select Select, click an enemy, and press Character scripting Character scripting.
  4. Press Code Code. Take out the script that is there, and type this one.
when I start
  stand still

when "alarm"
  say "Who is there?"
  chase the {Hero}
  1. Press Save Save.

Now step on your alarm block. The door opens, and behind it every enemy wakes up and comes for the hero.

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.