Your first automation
In this guide you build an intruder alarm: when a player or mob walks up to a detector, an alarm sounds. It takes about ten minutes and you do not need to know how to program.
What you need
Section titled “What you need”| Item | Recipe |
|---|---|
| 1 Programmable Computer | computer |
| 1 Network Repeater (the recipe makes 2) | repeater |
| 1 Entity Detector | detector |
| 1 Alarm Module | alarm |
| 1 Linking Tool | linking tool |
All of them use iron, copper and redstone and can be made before your first trip to the Nether. In creative mode they are all in the FilaSignal tab.
Build it
Section titled “Build it”-
Place the blocks. Put down the computer. Place the repeater within 32 blocks of it, and the detector and the alarm within 32 blocks of the repeater. Put the detector where visitors will walk past, such as next to your door. Blocks with a front, like the detector’s lens, face you when you place them.
-
Link the computer to the repeater. Hold the Linking Tool. Right-click the computer, then right-click the repeater. The message Devices linked. appears above your hotbar.
-
Link the devices. Right-click the repeater, then the detector. Right-click the repeater again, then the alarm.
-
Name the detector. Put the tool away so your hand is empty, and right-click the detector. A form opens. Type
gateinto the Device name box and select Save alias. While the form is open, check that its status says it says Connected to its computer. -
Name the alarm. Open the alarm’s form the same way, name it
sirenand select Save alias. Select Test to hear it, then Stop. -
Open the editor. Right-click the computer with an empty hand. The computer’s dashboard lists your devices. Select Open Editor.
-
Load the program. Select Starters. The first starter is Intruder alarm. It is the same file as this one:
starter-intruder-alarm.fsig // Starter: Intruder alarm (computer)// Sounds the Alarm Module "siren" when someone walks up to the Entity Detector "gate".// Name the two devices in their forms, link them to this computer, then start the program.const gate = detectors.named("gate")const siren = alarms.named("siren")// "on" runs the code between { and } every time the event happens.// entity tells you who arrived: entity.name, entity.hostile, entity.player and more.on gate.entityEnter(entity) {print(entity.name + " is at the gate!")siren.activate()} -
Save & Apply. Select Save & Apply, or press Ctrl+S. The program is checked and starts. The computer’s screen turns green to show that a program is running.
-
Test it. Walk more than 8 blocks away from the detector, then walk back. The alarm rings and glows. In the editor, select Debug ▸ to see the program’s output, such as Steve is at the gate!
How the program works
Section titled “How the program works”const gate = detectors.named("gate")gives the namegateto the detector you namedgate. It is a device constant: a name for a device, not the device’s position.on gate.entityEnter(entity) { ... }is an event handler. The code between{and}runs every time an entity enters the detector’s range.entityholds information about who arrived.siren.activate()sounds the alarm for its configured time, 10 seconds unless you change it.
Change it
Section titled “Change it”Try these one at a time. After each change, select Save & Apply.
- Only react to monsters: put
if entity.hostile {beforesiren.activate()and}after it. - Change the alarm sound: open the alarm’s form, type
chimeinto the Sound box and select Save. - Make the detector smaller: set its Radius to 4 in its form and select Save radius.
If it does not work
Section titled “If it does not work”- Nothing happens and the screen is green: walk farther away and back. Check that the detector’s form says Connected to its computer.
- The status says a name is not found: the names in the program must match the forms exactly, including upper and lower case.
- The screen is red: the program stopped on an error. Open the editor to read it, or see troubleshooting.
Next steps
Section titled “Next steps”- Show who arrived on a screen with a Display Module.
- Follow the beginner tutorials.
- Learn how networks and events work.