Advertisement
PappleFruit

Login-PC V1.0

Jul 27th, 2013
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. local pullEvent = os.pullEvent
  2.  
  3. --Change the 1 to the ID of the Check-PC
  4. local checker = 1
  5.  
  6. os.pullEvent = os.pullEventRaw
  7.  
  8. --Change "back" to the side of the wireless modem on your computer
  9. rednet.open("back")
  10.  
  11. term.clear()
  12. term.setCursorPos(1,1)
  13.  
  14. if term.isColor() then
  15.   term.setTextColor(16384)
  16. end
  17. print("--------Login--------------------------------------\n")
  18.  
  19. if term.isColor() then
  20.   term.setTextColor(16)
  21. end
  22.  
  23. write("Username: ")
  24. local user = read()
  25. write("Password: ")
  26. local pass = read("*")
  27.  
  28. rednet.send(checker, user)
  29. sleep(.5)
  30. rednet.send(checker, pass)
  31. local id, message = rednet.receive()
  32.  
  33. if message == "Termination" and id == checker then
  34.   if term.isColor() then
  35.     term.setTextColor(256)
  36.   end
  37.   term.clear()
  38.   term.setCursorPos(1,9)
  39.   os.pullEvent = pullEvent
  40.   print("You have 30 seconds to terminate the Password-Computer.")
  41.   sleep(30)
  42.   os.reboot()
  43. end
  44.  
  45. if message == "ok" and id == checker then
  46.   if term.isColor() then
  47.     term.setTextColor(32)
  48.   end
  49.   print("\nPassword accepted")
  50.   sleep(2)
  51.   term.clear()
  52.   term.setCursorPos(1,1)
  53. else
  54.   if term.isColor() then
  55.     term.setTextColor(16384)
  56.   end
  57.   print("\nPassword denied")
  58.   sleep(2)
  59.   os.reboot()
  60. end
  61.  
  62. term.setTextColor(colors.white)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement