Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Adjustable Configuration Settings --
- local door_delay = 5 -- The amount of time, in seconds, that a door should stay open.
- -- DO NOT EDIT ANYTHING BELOW THIS LINE!--
- local component = require("component")
- local event = require("event")
- local os = require("os")
- local fs = require("filesystem")
- local sides = require("sides")
- local auth = require("auth")
- local crfront = component.get("c8dd0")
- local crback = component.get("70d00")
- -- local crfrontlamp = component.get("0c47c")
- -- local crbacklamp = component.get("356ef")
- -- local function setState(lamp,state)
- -- if state == "auth" then
- -- component.proxy(lamp).setColor(0x00FF00)
- -- elseif state == "unauth" then
- -- component.proxy(lamp).setColor(0xFF0000)
- -- else ol.setColor(0x000000)
- -- end
- -- end
- local function openDoor(door)
- door.toggle()
- -- setState("auth")
- os.sleep(door_delay)
- door.toggle()
- -- setState()
- return
- end
- local authorized = {}
- for line in io.lines("/etc/auth.dat") do
- table.insert(authorized, line)
- end
- function controlDoorFront(_,addr, playerName, data, UUID, locked)
- for i = 1,#authorized do
- --print("Checking index #" .. i .. " for a match against: " .. UUID)
- if UUID == authorized[i] then
- --print("Control Room Door opening for " .. playerName .. ".")
- auth.userLog(playerName, "Control_Room")
- local door = component.proxy(crfront)
- openDoor(door)
- break
- elseif UUID ~= authorized[i] then
- --print("Card not authorized!")
- end
- end
- end
- function controlDoorBack(_,addr, playerName, data, UUID, locked)
- for i = 1,#authorized do
- --print("Checking index #" .. i .. " for a match against: " .. UUID)
- if UUID == authorized[i] then
- --print("Control Room Door opening for " .. playerName .. ".")
- auth.userLog(playerName, "Control_Room")
- local door = component.proxy(crback)
- openDoor(door)
- break
- elseif UUID ~= authorized[i] then
- --print("Card not authorized!")
- end
- end
- end
- function start(arg)
- event.listen("controlDoorBack", controlDoorBack)
- event.listen("controlDoorFront", controlDoorFront)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement