mj41374

ComplexPassword

Jun 26th, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --version2
  2.  
  3. local monitor = peripheral.wrap("monitor_0")
  4.  
  5. --greeting function
  6. function Greet()
  7.   monitor.setBackgroundColor(colors.blue)
  8.   monitor.setTextColor(colors.yellow)
  9.   monitor.setCursorPos(1,1)
  10.   monitor.setTextScale(3)
  11.   monitor.clear()
  12.   monitor.write("Speak Friend")
  13.   monitor.setCursorPos(3,2)
  14.   monitor.write("and Enter")
  15. end
  16.  
  17. function Wrong()
  18.   monitor.setBackgroundColor(colors.red)
  19.   monitor.setTextColor(colors.black)
  20.   monitor.setCursorPos(2,2)
  21.   monitor.setTextScale(4)
  22.   monitor.clear()
  23.   monitor.write("WRONG!")
  24. end
  25.  
  26. function Right()
  27.   monitor.setBackgroundColor(colors.green)
  28.   monitor.setTextColor(colors.white)
  29.   monitor.setCursorPos(2,2)
  30.   monitor.setTextScale(4)
  31.   monitor.clear()
  32.   monitor.write("Welcome!")
  33. end
  34.  
  35. --password function
  36. function PWD()
  37.   while true do
  38.     redstone.setOutput("back", true)
  39.     term.clear()
  40.     term.setCursorPos(1, 1)
  41.     print("Enter Password:")
  42.     input = read("*")
  43.     if input == "friend" then
  44.       redstone.setOutput("back", false)
  45.       Right()
  46.       sleep(4)
  47.       redstone.setOutput("back", true)
  48.       Greet()
  49.     else
  50.       Wrong()
  51.       sleep(5)
  52.       Greet()
  53.     end
  54.   end
  55. end
  56.  
  57. --Main Program  
  58. Greet()
  59. PWD()
Advertisement
Add Comment
Please, Sign In to add comment