Advertisement
Mackan90096

Mackos

Mar 13th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1.  
  2. local debugMode = true -- Set to false to prevent exiting to craftOS
  3. local pullEvent = os.pullEvent
  4. os.pullEvent = os.pullEventRaw
  5.  
  6.  
  7.  
  8. Version = "Alpha [0.1]"
  9.  
  10. function start()
  11. term.clear()
  12. term.setCursorPos(1,1)
  13. print("Welcome to MackOs version " ..Version)
  14. term.setCursorPos(1,3)
  15. print("What would you like to do?")
  16. term.setCursorPos(1,4)
  17. print("[1] Login")
  18. term.setCursorPos(1,5)
  19. print("[2] Register")
  20. term.setCursorPos(1,6)
  21. print("[3] Reboot Computer")
  22. term.setCursorPos(1,7)
  23. print("[4] Shutdown Computer")
  24. term.setCursorPos(1,8)
  25. print("[5] Generate a password")
  26. term.setCursorPos(1,10)
  27.  
  28. write("Input a number: ")
  29.  
  30.  
  31. local input = read()
  32. if input == "1" then
  33. login()
  34. elseif input == "2" then
  35. register()
  36. elseif input == "3" then
  37. term.clear()
  38. term.setCursorPos(1,1)
  39. print("Rebooting in 2 seconds!")
  40. sleep(2)
  41. os.reboot()
  42. elseif input == "4" then
  43. term.clear()
  44. term.setCursorPos(1,1)
  45. print("Shutting down in 2 seconds!")
  46. sleep(2)
  47. os.shutdown()
  48. elseif input == "5" then
  49. term.clear()
  50. term.setCursorPos(1,1)
  51. print("This is yet to be implemented")
  52. sleep(2)
  53. term.clear()
  54. start()
  55. else
  56. term.clear()
  57. term.setCursorPos(1,1)
  58. print("Cant understand!")
  59. sleep(1)
  60. term.clear()
  61. start()
  62. end
  63. end
  64.  
  65. function register()
  66. term.clear()
  67. term.setCursorPos(1,1)
  68. print("Registering")
  69. term.setCursorPos(1,3)
  70. write("Username: ")
  71. local usrName = read()
  72. term.setCursorPos(1,4)
  73. write("Password: ")
  74. local pass = read("*")
  75. fs.makeDir("users")
  76. local file = fs.open("users/"..usrName, "a")
  77. file.writeLine(pass)
  78. file.close()
  79. sleep(0.5)
  80. term.clear()
  81. term.setCursorPos(1,1)
  82. print("Registered!")
  83. sleep(0.5)
  84. term.clear()
  85. start()
  86.  
  87. end
  88.  
  89.  
  90. function login()
  91. term.clear()
  92. term.setCursorPos(1,1)
  93. print("Logging in")
  94. term.setCursorPos(1,3)
  95. write("Username: ")
  96. usrName = read()
  97. write("Password: ")
  98. local pass = read("*")
  99. file = fs.open("users/"..usrName,"r")
  100. local fileData = {}
  101. local line = file.readLine()
  102. repeat
  103. table.insert(fileData, line)
  104. line = file.readLine()
  105. until line == nil -- readLine()
  106. file.close()
  107. local passFromFile = fileData[1]
  108. if pass == passFromFile then
  109. term.clear()
  110. term.setCursorPos(1,1)
  111. print("Login succeded!")
  112. sleep(1)
  113. term.clear()
  114. start2()
  115. else
  116. term.clear()
  117. term.setCursorPos(1,1)
  118. print("Login failed!")
  119. sleep(1)
  120. term.clear()
  121. start()
  122. end
  123. end
  124.  
  125. function start2()
  126. term.clear()
  127. term.setCursorPos(1,1)
  128. print("Running MackOs version " ..Version)
  129. term.setCursorPos(1,2)
  130. print("Logged in as " ..usrName)
  131. term.setCursorPos(1,4)
  132. print("[1] Logout")
  133. term.setCursorPos(1,5)
  134. print("[2] Calculator")
  135. term.setCursorPos(1,6)
  136. print("[3] Games")
  137. term.setCursorPos(1,7)
  138. print("[4] Delete account")
  139. term.setCursorPos(1,8)
  140. print("[5] Exit to CraftOs")
  141. term.setCursorPos(1,9)
  142. print("[6] Calendar (Made by TheOiginalBIT")
  143. local input = read()
  144. if input == "1" then
  145. term.clear()
  146. term.setCursorPos(1,1)
  147. print("Logging out")
  148. sleep(1)
  149. term.clear()
  150. start()
  151. elseif input == "2" then
  152. term.clear()
  153. term.setCursorPos(1,1)
  154. print("Starting Calulator")
  155. sleep(1)
  156. term.clear()
  157. sleep(0.1)
  158. calc()
  159. elseif input == "3" then
  160. term.clear()
  161. term.setCursorPos(1,1)
  162. print("Opening games")
  163. sleep(1)
  164. term.clear()
  165. games()
  166. elseif input == "4" then
  167. term.clear()
  168. term.setCursorPos(1,1)
  169. print("Opening delete function")
  170. sleep(1)
  171. term.clear()
  172. delacc()
  173. elseif input == "5" and debugMode then
  174. os.pullEvent = pullEvent
  175. term.clear()
  176. term.setCursorPos(1,1)
  177. print("You can press ctrl+t now")
  178. while true do os.pullEvent() end
  179. elseif input == "5" then
  180. term.clear()
  181. print("Starting calendar by TheOriginalBIT")
  182. sleep(1)
  183. term.clear()
  184. calendar()
  185. else
  186. term.clear()
  187. error1()
  188. end
  189. end
  190.  
  191. function calendar()
  192. --[[
  193. Author: TheOriginalBIT
  194. Version: 1.1
  195. Created: 03 Feb 2013
  196. Last Update: 10 Mar 2013
  197.  
  198. License:
  199.  
  200. COPYRIGHT NOTICE
  201. Copyright © 2013 Joshua Asbury a.k.a TheOriginalBIT [
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement