Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local event = require("event")
- local os = require("os")
- local door = component.os_door
- local char_space = string.byte(" ")
- local running = true
- function unknownEvent()
- end
- local myEventHandlers = setmetatable({}, { __index = function() return unknownEvent end })
- function myEventHandlers.key_up(adress, char, code, playerName)
- if (char == char_space) then
- running = false
- end
- end
- local function openDoor()
- door.toggle()
- os.sleep(3)
- door.toggle()
- return
- end
- local authorized = { "7aa03fe4-b3e7-496e-a6e4-abedcd11f50b","Herpderp" }
- function myEventHandlers.magData(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("Door opening for " .. playerName .. ".")
- openDoor()
- break
- elseif UUID ~= authorized[i] then
- print("Card not authorized!")
- end
- end
- end
- function handleEvent(eventID, ...)
- if (eventID) then -- can be nil if no event was pulled for some time
- myEventHandlers[eventID](...) -- call the appropriate event handler with all remaining arguments
- end
- end
- while running do
- handleEvent(event.pull())
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement