Plazter

Advanced Player sensor

Aug 30th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. s = peripheral.find("openperipheral_sensor")
  2.  
  3. whitelist = {}
  4. sp = 2
  5.  
  6.  
  7. function list()
  8.   if fs.exists("whitelist") == false then
  9.     shell.run("edit whitelist")
  10.     else
  11.     print("whitelist already exist!")
  12.     sleep(1)
  13.     term.clear()
  14.     term.setCursorPos(1,1)
  15.   end
  16. end
  17.  
  18. function getList()
  19.   local datafile = fs.open("whitelist", "r")
  20.   for name in datafile.readLine do         
  21.     whitelist[name:lower()] = true
  22.   end
  23.   datafile.close()
  24.  
  25. function Auth()
  26.   term.setCursorPos(1,10)
  27.     for  t, result in ipairs(s.getPlayers()) do
  28.     local name = result.name:lower()
  29.     if whitelist[name] then
  30.       -- if whitelist
  31.       else
  32.       -- if not whitelist
  33.     end
  34.   end
  35. end
  36.  
  37.  
  38. list()
  39. getList()
  40.  
  41. while true do
  42.   Auth()
  43.   sleep(sp)
  44. end
Add Comment
Please, Sign In to add comment