Skip to content

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.

The Door guest book starter records who came in and who was refused:

starter-door-log.fsig
// 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)
}

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.

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()
}
  • accessGranted and accessDenied run on the controller after it decided. player has name, uuid, result and granted.
  • 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.