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