Advertisement
onwardprogress

door

Dec 8th, 2015
1,094
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.72 KB | None | 0 0
  1. local pullEvent = os.pullEvent
  2. local pass1 = "MASTER"
  3. local pass2 = "ADMIN"
  4. local pass3 = "PERSONNEL"
  5. local pass4 = "GUEST"
  6. local opentime = 4
  7. local pause = 3
  8. local access = 2
  9. local h = fs.open("/securityVariables", "r")
  10. local access = tonumber(h.readLine())
  11. h.close()
  12. local h = fs.open("/clearanceVariables", "r")
  13. local input = h.readLine()
  14. h.close()
  15. os.pullEvent = os.pullEventRaw
  16.     term.clear()
  17.     term.setCursorPos(1,1)
  18.     if input == pass1 then
  19.         term.clear()
  20.         print("Type OPEN or PERMS, or END to Terminate program")
  21.         local command = read()
  22.             if command =="OPEN" then
  23.             shell.run("eject left")
  24.             shell.run("eject right")
  25.             term.clear()
  26.             print("Opening door")
  27.                 redstone.setOutput("back", true)
  28.                 sleep(opentime)
  29.                 redstone.setOutput("back", false)
  30.             elseif command =="END" then
  31.             term.clear()
  32.                 print("Type [EXIT] to terminate program, or [BACK] to return to the login.")
  33.             local ender = read()
  34.                 if ender == "BACK" then
  35.                     term.clear()
  36.                     print("Returning to login")
  37.                     sleep(pause)
  38.                 elseif ender == "EXIT" then
  39.                     term.clear()
  40.                     print("Exiting ID Badge Program.")
  41.                     sleep(pause)
  42.                     error()
  43.                 else
  44.                     term.clear()
  45.                     print("That was not a valid command, returnign to login.")
  46.                     sleep(pause)
  47.                 end
  48.                 os.pullEvent = pullEvent
  49.             elseif command =="PERMS" then
  50.             print("[NONE], [MODERATE], or [STRICT]")
  51.             local level = read()
  52.                 if level =="NONE" then
  53.                     access = 0
  54.                 h = fs.open("/securityVariables", "w")
  55.                 h.writeLine(access)
  56.                 h.close()
  57.                 term.clear()
  58.                 print("Access now open to anyone with an ID card")
  59.                 elseif level =="MODERATE" then
  60.                     access = 1
  61.                 h = fs.open("/securityVariables", "w")
  62.                 h.writeLine(access)
  63.                 h.close()
  64.                 term.clear()
  65.                 print("Access now open to Personnel, facility administrators and the MASTER id card")
  66.                 elseif level =="STRICT" then
  67.                     access = 2
  68.                 h = fs.open("/securityVariables", "w")
  69.                 h.writeLine(access)
  70.                 h.close()
  71.                 term.clear()
  72.                 print("Access now limited to facility administrators and the MASTER id card")
  73.                 else
  74.                 access = 2
  75.                 h = fs.open("/securityVariables", "w")
  76.                 h.writeLine(access)
  77.                 h.close()
  78.                 term.clear()
  79.                     print("That was not an access level. Setting access level to STRICT")
  80.                 sleep(pause)
  81.                 end
  82.             else
  83.             term.clear()
  84.                 print("You put in something that was not a command")
  85.             sleep(pause)
  86.             end
  87.     elseif input == pass2 then
  88.             shell.run("eject left")
  89.             shell.run("eject right")
  90.         term.clear()
  91.         print("Opening door")
  92.         redstone.setOutput("back", true)
  93.             sleep(opentime)
  94.             redstone.setOutput("back", false)
  95.     elseif input == pass3 then
  96.         if access < 2 then
  97.             shell.run("eject left")
  98.             shell.run("eject right")
  99.             term.clear()
  100.             print("Opening door")
  101.                 redstone.setOutput("back", true)
  102.                 sleep(opentime)
  103.                 redstone.setOutput("back", false)
  104.         elseif access > 1 then
  105.             shell.run("eject left")
  106.             shell.run("eject right")
  107.             term.clear()
  108.             print("Insufficient Clearance Level for this room.")
  109.             sleep(pause)
  110.         end
  111.     elseif input == pass4 then
  112.         if access < 1 then
  113.             shell.run("eject left")
  114.             shell.run("eject right")
  115.             term.clear()
  116.             print("Opening door")
  117.                 redstone.setOutput("back", true)
  118.                 sleep(opentime)
  119.                 redstone.setOutput("back", false)
  120.         elseif access > 0 then
  121.             shell.run("eject left")
  122.             shell.run("eject right")
  123.             term.clear()
  124.             print("Insufficient Clearance Level for this room.")
  125.             sleep(pause)
  126.         end
  127.     else
  128.         term.clear()
  129.             print("That is not an access card.")
  130.         sleep(pause)
  131.     end
  132. shell.run("cd /")
  133. shell.run("mainloop")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement