Programmable access controller
An Access Controller already opens a door for allowed players without any program. A drive program adds behavior on top: it records visitors and warns the computer about suspicious attempts. It cannot change who is allowed in: that stays with the owner.
You need: a computer, a Network Repeater, an Access Controller with a door next to it, an Alarm Module named
siren and a Programmable Data Drive.
1. The guest book starter
Section titled “1. The guest book starter”The Door guest book starter records who came in and who was refused:
// Starter: Door guest book (Access Controller drive)// Device: access_controller// An Access Controller already opens the door for allowed players without any program: add players in its// form. This program adds a guest book: it remembers who came in and who was turned away.on device.accessGranted(player) { print("Welcome, " + player.name) storage.append("visitors", player.name)}
on device.accessDenied(player) { storage.append("refused", player.name)}2. Warn about repeated attempts
Section titled “2. Warn about repeated attempts”Extend it so that three refused attempts in a row send a custom event to the network:
global refusedInARow = 0
on device.accessGranted(player) { refusedInARow = 0 print("Welcome, " + player.name) storage.append("visitors", player.name)}
on device.accessDenied(player) { refusedInARow++ storage.append("refused", player.name) if refusedInARow >= 3 { events.emit("door.warning", {who: player.name, tries: refusedInARow}) }}Write it onto a drive of type access_controller, install it in the controller and select Start.
3. The computer sounds the alarm
Section titled “3. The computer sounds the alarm”const siren = alarms.named("siren")
on events.custom("door.warning", warning, sender) { if sender.kind is not "access_controller" { return } print(warning.who + " was refused " + str(warning.tries) + " times") siren.activate()}How it works
Section titled “How it works”accessGrantedandaccessDeniedrun on the controller after it decided.playerhasname,uuid,resultandgranted.- The drive program cannot sound the alarm itself: drive programs only control their own device. Instead it sends a custom event, and the computer decides what to do.
- The computer checks
sender.kind. The server fills in the sender, so another program cannot pretend to be the door.
The lists visitors and refused grow with every visit. Trim them like in
detection history if many people pass, because a drive holds
64 KiB.