Kodos

PCL Door RC program

Nov 7th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Adjustable Configuration Settings --
  2.  
  3. local door_delay = 5 -- The amount of time, in seconds, that a door should stay open.
  4.  
  5. -- DO NOT EDIT ANYTHING BELOW THIS LINE!--
  6.  
  7.  
  8. local component = require("component")
  9. local event = require("event")
  10. local os = require("os")
  11. local fs = require("filesystem")
  12. local sides = require("sides")
  13. local auth = require("auth")
  14.  
  15. local crfront = component.get("c8dd0")
  16. local crback = component.get("70d00")
  17. -- local crfrontlamp = component.get("0c47c")
  18. -- local crbacklamp = component.get("356ef")
  19.  
  20. -- local function setState(lamp,state)
  21. -- if state == "auth" then
  22. -- component.proxy(lamp).setColor(0x00FF00)
  23. -- elseif state == "unauth" then
  24. -- component.proxy(lamp).setColor(0xFF0000)
  25. -- else ol.setColor(0x000000)
  26. -- end
  27. -- end
  28.  
  29. local function openDoor(door)
  30.   door.toggle()
  31. --  setState("auth")
  32.   os.sleep(door_delay)
  33.   door.toggle()
  34. --  setState()
  35.   return
  36. end
  37.  
  38. local authorized = {}
  39.  
  40. for line in io.lines("/etc/auth.dat") do
  41. table.insert(authorized, line)
  42. end
  43.  
  44. function controlDoorFront(_,addr, playerName, data, UUID, locked)
  45.   for i = 1,#authorized do
  46.     --print("Checking index #" .. i .. " for a match against: " .. UUID)
  47.     if UUID == authorized[i] then
  48.       --print("Control Room Door opening for " .. playerName .. ".")
  49.       auth.userLog(playerName, "Control_Room")
  50.       local door = component.proxy(crfront)
  51.       openDoor(door)
  52.       break
  53.     elseif UUID ~= authorized[i] then
  54.       --print("Card not authorized!")
  55.     end
  56.   end
  57. end
  58.  
  59. function controlDoorBack(_,addr, playerName, data, UUID, locked)
  60.   for i = 1,#authorized do
  61.     --print("Checking index #" .. i .. " for a match against: " .. UUID)
  62.     if UUID == authorized[i] then
  63.       --print("Control Room Door opening for " .. playerName .. ".")
  64.       auth.userLog(playerName, "Control_Room")
  65.       local door = component.proxy(crback)
  66.      
  67.       openDoor(door)
  68.       break
  69.     elseif UUID ~= authorized[i] then
  70.       --print("Card not authorized!")
  71.     end
  72.   end
  73. end
  74.  
  75. function start(arg)
  76.   event.listen("controlDoorBack", controlDoorBack)
  77.   event.listen("controlDoorFront", controlDoorFront)
  78. end
Advertisement
Add Comment
Please, Sign In to add comment