Computer_Craft_Coder

Login

May 18th, 2015
2,069
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. --[[ Login screen ]]--
  2.  
  3. username = "Admin"
  4. Access = "Login"
  5. password = "password"
  6. currentVersion = "1.3.2"
  7. updateAvailable = "false"
  8. autoUpdate = "true"
  9. os.pullEvent = os.pullEventRaw
  10. --[[ functions ]]--
  11.  
  12. function startscreen(print)
  13. term.clear()
  14. term.setCursorPos(1,1)
  15. print("+========+")
  16. print("|Craft OS|")
  17. print("+========+")
  18. print("")
  19. print("+=======================+")
  20. print("|Username: |")
  21. print("+=======================+")
  22. print("")
  23. print("+=======================+")
  24. print("|Password: |")
  25. print("+=======================+")
  26. print("")
  27. print("Access: "..Access.."")
  28.  
  29. end
  30.  
  31. function login()
  32. term.setCursorPos(12,6)
  33. unbox = read()
  34. if unbox == "update" then
  35. autoupdate()
  36. elseif unbox ~= username then
  37. term.setCursorPos(9,13)
  38. print("Incorrect username!")
  39. sleep(2)
  40. shell.run("startup")
  41. else
  42. term.setCursorPos(1,13)
  43. term.setCursorPos(1,13)
  44. term.setCursorPos(12,10)
  45. pwbox = read("*")
  46. if pwbox == password then
  47. term.setCursorPos(1,13)
  48. print("")
  49. term.setCursorPos(1,13)
  50. Access = "Granted!"
  51. print("Access: "..Access.."")
  52. sleep(3)
  53. term.clear()
  54. term.setCursorPos(1,1)
  55. else
  56. os.reboot()
  57. end
  58. end
  59. end
  60.  
  61. function updateCheck()
  62. term.clear()
  63. term.setCursorPos(1,1)
  64. print("+--------------------------+")
  65. print("|Checking for updates... |")
  66. print("+--------------------------+")
  67. print("+--------------------------+")
  68. print("| |")
  69. print("+--------------------------+")
  70. term.setCursorPos(2,5)
  71. textutils.slowPrint("//////////////////////////", 8)
  72. term.clear()
  73. term.setCursorPos(1,1)
  74. local h, version = http.get( "http://pastebin.com/raw.php?i=9nXEnf7x" )
  75. if h then
  76. version = h.readAll()
  77. if version ~= currentVersion then
  78. print("+--------------------------+")
  79. print("|Update found! |")
  80. print("+--------------------------+")
  81. print("+--------------------------+")
  82. print("|Version: |")
  83. print("+--------------------------+")
  84. print("+--------------------------+")
  85. print("|Downloading... |")
  86. print("+--------------------------+")
  87. term.setCursorPos(11,5)
  88. print(version)
  89. sleep(3)
  90. shell.run("pastebin run JuYtAwrk")
  91. else
  92. print("+--------------------------+")
  93. print("|Current update owned! |")
  94. print("+--------------------------+")
  95. end
  96. else
  97. print( "Couldn't connect to pastebin!" )
  98. end
  99. end
  100.  
  101. updateCheck()
  102. startscreen(print)
  103. login()
Advertisement
Add Comment
Please, Sign In to add comment