Advertisement
Spectrewiz

Security

Aug 28th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.64 KB | None | 0 0
  1. -------------- startup class --------------
  2. local attemptsLeft = 3
  3.  
  4. local function checkLock(side)
  5.     if redstone.getInput(side) == true then
  6.         term.clear()
  7.         term.setCursorPos(18,9)
  8.         print("TERMINAL LOCKED")
  9.         term.setCursorBlink(false)
  10.         sleep(5)
  11.         os.shutdown()
  12.     end
  13. end
  14.  
  15. local function main()
  16.     term.clear()
  17.     term.setCursorPos(1,1)
  18.     print("Open, close, or Reset Password? (o/open, c/close, or r/reset)")
  19.     input2 = string.lower(read())
  20.     if input2 == "o" or input2 == "open" then
  21.         shell.run "OPEN"
  22.         os.shutdown()
  23.     elseif input2 == "c" or input2 == "close" then
  24.         shell.run "CLOSE"
  25.         os.shutdown()
  26.     elseif input2 == "r" or input2 == "reset" then
  27.         term.clear()
  28.         term.setCursorPos(1,1)
  29.         print("Old Password:")
  30.         input3 = read()
  31.         if input3 == pass then
  32.             term.clear()
  33.             term.setCursorPos(1,1)
  34.             print("New Password:")
  35.             password = io.open("password", "w")
  36.             password:write(read())
  37.             password:close()
  38.             print("Reset!")
  39.             sleep(2)
  40.             os.shutdown()
  41.         else
  42.             print("Incorrect")
  43.             sleep(2)
  44.             os.shutdown()
  45.         end
  46.     else
  47.         return
  48.     end
  49. end
  50.  
  51. local function shutdown()
  52.     print("Shut down? (y/yes or n/no)")
  53.     input2 = string.lower(read())
  54.     if input2 == "y" or input2 == "yes" then
  55.         print("Shutting down...")
  56.         sleep(2)
  57.         os.shutdown()
  58.     else
  59.         main()
  60.         shutdown()
  61.     end
  62. end
  63.  
  64. term.clear()
  65. term.setCursorPos(1,5)
  66. print("  ______________________________________________\n |  _____ _____ _                  _____ _____  |\n | |   __|   __| |_ ___ ___ ___   |     |   __| |\n | |  |  |__   |  _| . |  _| -_|  |  |  |__   | |\n | |_____|_____|_| |___|_| |___|  |_____|_____| |\n |______________________________________________|\n\n                         Made by Spectrewiz\n                                  V1.4")
  67. sleep(1)
  68. while attemptsLeft > 0 do
  69.     term.clear()
  70.     term.setCursorPos(1,1)
  71.     password = io.open("password")
  72.     pass = password.read("*all")
  73.     password:close()
  74.     PasswordText = "Password:                      Attempts Left: "
  75.     for i = 1,attemptsLeft - 1,1 do
  76.         PasswordText = PasswordText .. "* "
  77.     end
  78.     print(PasswordText)
  79.     input = read()
  80.     if input == pass then
  81.         main()
  82.         shutdown()
  83.     else
  84.         print("Incorrect")
  85.         attemptsLeft = attemptsLeft - 1
  86.         sleep(1)
  87.     end
  88. end
  89. term.clear()
  90. term.setCursorPos(14, 9)
  91. print("Notifying Administrator...")
  92. redstone.setOutput("top", true)
  93. sleep(5)
  94. redstone.setOutput("top", false)
  95. os.shutdown()
  96.  
  97.  
  98.  
  99. -------------- OPEN class --------------
  100. local function frame(motor)
  101.     if motor == "up" then
  102.         redstone.setBundledOutput("left", colors.blue)
  103.         sleep(1)
  104.         redstone.setBundledOutput("left", 0)
  105.         sleep(1)
  106.     elseif motor == "down" then
  107.         redstone.setBundledOutput("left", colors.red)
  108.         sleep(1)
  109.         redstone.setBundledOutput("left", 0)
  110.         sleep(1)
  111.     end
  112. end
  113.  
  114. for i = 1,2,1 do
  115.     frame("down")
  116. end
  117.  
  118.  
  119.  
  120. -------------- CLOSE class --------------
  121. local function frame(motor)
  122.     if motor == "up" then
  123.         redstone.setBundledOutput("left", colors.blue)
  124.         sleep(1)
  125.         redstone.setBundledOutput("left", 0)
  126.         sleep(1)
  127.     elseif motor == "down" then
  128.         redstone.setBundledOutput("left", colors.red)
  129.         sleep(1)
  130.         redstone.setBundledOutput("left", 0)
  131.         sleep(1)
  132.     end
  133. end
  134.  
  135. for i = 1,2,1 do
  136.     frame("up")
  137. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement