Advertisement
OpposingGeek

Untitled

Apr 21st, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. triesRemaining = 3
  2.  
  3. function getUsers()
  4. rednet.broadcast("getUser", "getUser")
  5. id, msg, prot = rednet.receive()
  6. if prot == "getUser" then
  7. return msg
  8. end
  9. end
  10.  
  11. function updateScreen()
  12. os.pullEvent("char")
  13. term.clear()
  14. term.setCursorPos(1,1)
  15. uname = getUsers()
  16. term.clear()
  17. term.setCursorPos(1,1)
  18. print("Welcome, " .. uname .."!")
  19. term.setCursorPos(1,2)
  20. os.queueEvent("key", 15)
  21. end
  22.  
  23. function confirmPass()
  24. inp = read("*")
  25. rednet.broadcast(inp, "pass")
  26. while true do
  27. id, msg, prot = rednet.receive()
  28. if prot == "pass" then
  29. if msg == "granted" then
  30. return true
  31. end
  32. if msg == "denied" then
  33. return false
  34. end
  35. end
  36. end
  37. end
  38.  
  39. function getPassword()
  40. pass = confirmPass()
  41. if pass == true then
  42. print("Access granted.")
  43. triesRemaining = 3
  44. redstone.setBundledOutput("bottom", colors.red)
  45. sleep(5)
  46. redstone.setBundledOutput("bottom", 0)
  47. else
  48. triesRemaining = triesRemaining - 1
  49. print("Incorrect. " .. triesRemaining .. " tries remaining")
  50. sleep(3)
  51. if triesRemaining == 0 then
  52. print("Prepare for your death")
  53. sleep(0.25)
  54. redstone.setBundledOutput("bottom", colors.green)
  55. sleep(1)
  56. redstone.setBundledOutput("bottom", 0)
  57. triesRemaining = 3
  58. end
  59. end
  60. end
  61.  
  62. term.clear()
  63. term.setCursorPos(1,1)
  64. rednet.open("back")
  65. while true do
  66. parallel.waitForAll(updateScreen, getPassword)
  67. term.clear()
  68. term.setCursorPos(1,1)
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement