Advertisement
sethxi

Simple Auth

Jul 1st, 2014
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.81 KB | None | 0 0
  1. local list = {
  2.   "LiquidObsidian"
  3. }
  4.  
  5. os.pullEvent = os.pullEventRaw
  6.  
  7. local doorside = "right"
  8.  
  9. function table.contains(table, element)
  10.   for _, value in pairs(table) do
  11.     if value == element then
  12.       return true
  13.     end
  14.   end
  15.   return false
  16. end
  17.  
  18. term.clear()
  19. term.setCursorPos(1,1)
  20.  
  21. term.setTextColor(colors.blue)
  22. print("Simple Auth v1.0 by LiquidObsidian!")
  23.  
  24. while true do
  25. local event, detector, username = os.pullEvent()
  26.   if event == "player" then
  27.     if(table.contains(list, username)) then
  28.       rs.setOutput(doorside, true)
  29.       sleep(2)
  30.       rs.setOutput(doorside, false)
  31.  
  32.       term.setTextColor(colors.green)
  33.       print("<ACCESS GRANTED TO "..username..">")
  34.     else
  35.       term.setTextColor(colors.red)
  36.       print("<ACCESS DENIED TO "..username..">")
  37.     end
  38.   end
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement