Advertisement
Whiskee

Touch.lua

Apr 10th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. local event = require("event")
  2. local s = require("shell")
  3. local c = require("component")
  4. local rs = c.redstone
  5. local side = require("sides")
  6. local term = require("term")
  7. local gpu = c.gpu
  8. local RSIDE = side.top
  9.  
  10.  
  11. gpu.setResolution(30,15)
  12.  
  13. NAME = {"TotallyIridium", "Eatersoul12357", "Dinxton"}
  14. CLVL = {1,1,1}
  15. reqlvl = 5
  16.  
  17. --s.execute("wget -f https://pastebin.com/raw/4izJWFVj Names.lua")
  18.  
  19.  
  20. --term.clear()
  21.  
  22. --print("Touch To Open Door")
  23.  
  24. --local N = require("Names")
  25.  
  26.  
  27. function Door(name)
  28.  
  29.   local loop = true
  30.   local i = 1
  31.  
  32.   while loop do
  33.     if NAME[i] == name then
  34.       if CLVL[i] <= reqlvl then
  35.         loop = false
  36.         rs.setOutput(RSIDE,15)
  37.         print("Welcome, " .. NAME[i])
  38.         os.sleep(4)
  39.         rs.setOutput(RSIDE,0)
  40.         else
  41.         print("Access Dnied: Invalid Clearance Level")
  42.         loop = false  
  43.       end
  44.     end
  45. if i == 3 then
  46. loop = false
  47. end
  48.     i=i+1
  49.   end
  50.  
  51. end
  52.  
  53.  
  54. while true do
  55. term.clear()
  56. print("press to open door")
  57.  
  58.   local id, _, x, y, _, nickname = event.pullMultiple("touch", "interrupted")
  59.   if id == "interrupted" then
  60.     print("soft interrupt, closing")
  61.     break
  62.   elseif id == "touch" then
  63.  
  64.    Door(nickname)
  65.  
  66. --print("Name: ", nickname)
  67. --os.sleep(1)
  68.   end
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement