DrFair

FairPad DoorPassword

May 8th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. password = "1234"
  2. rednet.open("back")
  3. doorName = "ThaumcraftDoor"
  4. monitorSide = "top"
  5.  
  6. local Args = {...}
  7. if Args[1] == "update" then
  8. programName = shell.getRunningProgram()
  9. print("Updating.")
  10. fs.delete( programName )
  11. shell.run( "pastebin","get", "Gu2VWmBy", programName )
  12. print("Finished updating.")
  13. error()
  14. end
  15.  
  16. if not fs.exists( "fui" ) then
  17. print( "Performing first time setup." )
  18. shell.run( "pastebin","get", "306Ns1qg", "fui" )
  19. print("Finished. Please run program again.")
  20. error()
  21. end
  22.  
  23. read = ""
  24. os.loadAPI("fui")
  25. fui.setMonitorSide( monitorSide )
  26. os.sleep(1)
  27. w,h = fui.getSize()
  28. w = w + 1
  29. h = h + 1
  30.  
  31. function drawScreen()
  32. fui.clear()
  33. fui.drawButton( " ", " ", 1, 8, 1, 6 , "black", "white" )
  34. fui.drawButton( " ", "1", 2, 2, 2, 1 , "black", "gray" )
  35. fui.drawButton( " ", "2", 5, 2, 2, 1 , "black", "gray" )
  36. fui.drawButton( " ", "3", 2, 2, 4, 1 , "black", "gray" )
  37. fui.drawButton( " ", "4", 5, 2, 4, 1 , "black", "gray" )
  38. end
  39.  
  40. function checkPassword()
  41. if #read > 3 then
  42. if read == password then
  43. fui.drawButton( " ", " ", 2, 5, 2, 3 , "black", "lime" )
  44. msg = { [1]=doorName, [2]="toggle" }
  45. rednet.broadcast(textutils.serialize(msg))
  46. os.sleep(2)
  47. drawScreen()
  48. else
  49. fui.drawButton( " ", " ", 2, 5, 2, 3 , "black", "red" )
  50. os.sleep(2)
  51. drawScreen()
  52. end
  53. read = ""
  54. end
  55. end
  56.  
  57. drawScreen()
  58.  
  59. while true do
  60. fui.submitEvents()
  61. lastEvent = fui.getEvents()
  62. if fui.buttonPressed("1") and string.find( read, "1" ) == nil then
  63. fui.drawButton( " ", "1", 2, 2, 2, 1 , "black", "lightgray" )
  64. read = read.."1"
  65. checkPassword()
  66. elseif fui.buttonPressed("2") and string.find( read, "2" ) == nil then
  67. fui.drawButton( " ", "2", 5, 2, 2, 1 , "black", "lightgray" )
  68. read = read.."2"
  69. checkPassword()
  70. elseif fui.buttonPressed("3") and string.find( read, "3" ) == nil then
  71. fui.drawButton( " ", "3", 2, 2, 4, 1 , "black", "lightgray" )
  72. read = read.."3"
  73. checkPassword()
  74. elseif fui.buttonPressed("4") and string.find( read, "4" ) == nil then
  75. fui.drawButton( " ", "4", 5, 2, 4, 1 , "black", "lightgray" )
  76. read = read.."4"
  77. checkPassword()
  78. end
  79. end
Advertisement
Add Comment
Please, Sign In to add comment