Advertisement
Darking560

Player detector

Sep 16th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. local event
  2. local name
  3. local found
  4.  
  5. function pulse(color)
  6.    redstone.setBundledOutput("back", color)
  7.    sleep(0.4)
  8.    redstone.setBundledOutput("back", 0)
  9.    sleep(0.4)
  10. end
  11.  
  12. function door()
  13.    redstone.setBundledOutput("back", colors.white)
  14.    sleep(4)
  15.    redstone.setBundledOutput("back", 0)
  16. end
  17.  
  18. function floor()
  19.    for i = 1,3 do pulse(colors.magenta) end
  20.    sleep(4)
  21.    for i = 1,3 do pulse(colors.orange) end
  22. end
  23.  
  24. function reset()
  25.    name = ""
  26.    found = false
  27. end
  28.  
  29. function waitClick()
  30.    event, name = os.pullEvent("player")
  31.    print(name)
  32. end
  33.  
  34. function checkName()
  35.    file = io.open("perms", "r")
  36.    for line in file:lines() do
  37.       if name == line then
  38.          found = true
  39.       end
  40.    end
  41. end
  42.  
  43. function run()
  44.    if found == true then
  45.       print("Yay")
  46.       door()
  47.    else
  48.       print("Boo")
  49.       floor()
  50.    end
  51. end
  52. while true do
  53.   reset()
  54.   waitClick()
  55.   checkName()
  56.   run()
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement