SuicidalSTDz

EnderOS v1.8 Developmental

Jan 30th, 2013
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.19 KB | None | 0 0
  1. --License:
  2. --The code of "EnderOS" in any form is intellectual
  3. --property of SuicidalSTDz. You may not reproduce,
  4. --redistribute, or modify it in any way!
  5.  
  6. --IGNORE!
  7. --Replace this with your name and anyone else that is allowed on your computer
  8. playerDetection = false
  9. allowedPlayers = "SuicidalSTDz","Notch","direwolf20"
  10.  
  11.  
  12. reset()
  13. if not fs.exists("/.EnderOS/.startupInstalled") then
  14. local running = shell.getRunningProgram()
  15. print("EnderOS has detected a startup file that it clashes with!")
  16. print("EnderOS is about to delete this file and install itself in its place")
  17. print("Do you wish to continue? Yes or No?")
  18. local input = read()
  19. if input == "Yes" then
  20. shell.run("delete","startup")
  21. fs.move(running, "startup")
  22. reset()
  23. print("File removed and EnderOS implanted within the startup file")
  24. sleep(5)
  25. local newStartup = fs.open(".EnderOS/.startupInstalled", "w")
  26. newStartup:close()
  27. else
  28. os.reboot()
  29. end
  30. end
  31. function settingsChangeUser()
  32. reset()
  33. term.setTextColor(colors.orange)
  34. local passFile = io.open("/.EnderOS/.passInfo", "r")
  35. local passContents = passFile:read()
  36. passFile:close()
  37. print("Please enter your password: ")
  38. if read("*") ~= passContents then
  39. print("Invalid password")
  40. sleep(1.5)
  41. settingsChangeUser()
  42. else
  43. local user = ("/.EnderOS/.userInfo")
  44. io.open(user)
  45. local username = io.open(user, "w")
  46. print("Enter new username: ")
  47. writeUser = read()
  48. writeN = username:write(writeUser)
  49. username:close()
  50. print("Your new username is "..writeUser)
  51. sleep(2)
  52. start()
  53. end
  54. term.setTextColor(colors.white)
  55. end
  56. function settingsChangePass()
  57. reset()
  58. term.setTextColor(colors.orange)
  59. local passFile = io.open("/.EnderOS/.passInfo", "r")
  60. local passContents = passFile:read()
  61. passFile:close()
  62. print("Please enter your password: ")
  63. if read("*") ~= passContents then
  64. print("Invalid password")
  65. sleep(1.5)
  66. settingsChangePass()
  67. else
  68. local pass = ("/.EnderOS/.passInfo")
  69. io.open(pass)
  70. local password = io.open(pass, "w")
  71. print("Enter new password: ")
  72. local writePass = read("*")
  73. local writeN = password:write(writePass)
  74. password:close()
  75. print("Your new password is "..writePass)
  76. sleep(2)
  77. start()
  78. end
  79. term.setTextColor(colors.white)
  80. end
  81. function settingsChangeHint()
  82. reset()
  83. term.setTextColor(colors.orange)
  84. local passFile = io.open("/.EnderOS/.passInfo", "r")
  85. local passContents = passFile:read()
  86. passFile:close()
  87. print("Please enter your password: ")
  88. if read("*") ~= passContents then
  89. print("Invalid password")
  90. sleep(1.5)
  91. settingsChangeHint()
  92. else
  93. local hint = ("/.EnderOS/.userHint")
  94. io.open(hint)
  95. local uHint = io.open(hint, "w")
  96. print("Enter new hint: ")
  97. local writeHint = read("*")
  98. local writeN = uHint:write(writeHint)
  99. uHint:close()
  100. print("Your new hint is "..writeHint)
  101. sleep(2)
  102. start()
  103. end
  104. term.setTextColor(colors.white)
  105. end
  106. local version = "v1.8"
  107. userfile = shell.getRunningProgram()
  108. local dot = string.byte(shell.getRunningProgram())
  109. local v = ".(Period)"
  110.  
  111. function reset()
  112. term.clear()
  113. term.setCursorPos(1,1)
  114. end
  115. function userInfo()
  116. reset()
  117. fs.makeDir("/.EnderOS/")
  118. user = ("/.EnderOS/.userInfo")
  119. io.open(user)
  120. username = io.open(user, "w")
  121. print("Please enter your desired Username")
  122. writeUser = read()
  123. writeIsFailUser = username:write(writeUser)
  124. username:close()
  125. pass = ("/.EnderOS/.passInfo")
  126. io.open(pass)
  127. password = io.open(pass, "w")
  128. print("Please enter your desired Password")
  129. writePass = read("*")
  130. writeIsFailPass = password:write(writePass)
  131. password:close()
  132. hint = ("/.EnderOS/.userHint")
  133. io.open(hint)
  134. uHint = io.open(hint, "w")
  135. print("Please enter your desired Password hint")
  136. writeHint = read()
  137. writeIsFailHint = uHint:write(writeHint)
  138. uHint:close()
  139. local installC = fs.open("/.EnderOS/.EnderOSisInstalled", "w")
  140. installC:close()
  141. end
  142. function frame()
  143. print("+-------------------------------------------------+")
  144. for i = 1,17 do
  145. print("| |")
  146. end
  147. term.write("+-------------------------------------------------+")
  148. end
  149. function no()
  150. term.clear()
  151. term.setTextColor(colors.red)
  152. term.setCursorPos(1,1)
  153. print("Sorry, I have not coded this in yet. Please be patient.")
  154. sleep(3)
  155. end
  156. function screen()
  157. reset()
  158. term.setTextColor(colors.lime)
  159. print("+-------------------------------------------------+")
  160. print("| |")
  161. print("| ")
  162. term.setCursorPos(19,3)
  163. term.setTextColor(colors.purple)
  164. write("EnderOS "..version)
  165. term.setTextColor(colors.lime)
  166. term.setCursorPos(31,3)
  167. print(" |")
  168. print("| |")
  169. print("| |")
  170. print("| |")
  171. print("| |")
  172. print("| ")
  173. term.setCursorPos(10,8)
  174. term.setTextColor(colors.orange)
  175. print("Username:")
  176. term.setCursorPos(19,8)
  177. print(" ")
  178. term.setCursorPos(50,8)
  179. term.setTextColor(colors.lime)
  180. print(" |")
  181. print("| |")
  182. print("| ")
  183. term.setTextColor(colors.orange)
  184. term.setCursorPos(10,10)
  185. print("Password:")
  186. term.setCursorPos(19,10)
  187. print(" ")
  188. term.setCursorPos(50,10)
  189. term.setTextColor(colors.lime)
  190. print(" |")
  191. print("| |")
  192. print("| |")
  193. print("| ")
  194. term.setCursorPos(8,13)
  195. term.setTextColor(colors.blue)
  196. print("forgot password ")
  197. term.setCursorPos(50,13)
  198. term.setTextColor(colors.lime)
  199. print(" |")
  200. print("| |")
  201. print("| |")
  202. print("| |")
  203. print("| |")
  204. print("| |")
  205. write("+-------------------------------------------------+")
  206. end
  207. function click()
  208. local userHint = io.open("/.EnderOS/.userHint", "r")
  209. hintContents = userHint:read()
  210. userHint:close()
  211. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  212. if button == 1 then
  213. if (xPos >=8 and xPos <=22 and yPos == 13) then
  214. term.setCursorPos(10,15)
  215. term.setTextColor(colors.red)
  216. print("Hint: "..hintContents)
  217. term.setTextColor(colors.white)
  218. click()
  219. elseif (xPos >=10 and xPos <=18 and yPos == 8) then
  220. term.setCursorPos(20,8)
  221. else
  222. screen()
  223. click()
  224. end
  225. else
  226. click()
  227. end
  228. end
  229. function login()
  230. click()
  231. local userFile = io.open("/.EnderOS/.userInfo", "r")
  232. userContents = userFile:read()
  233. userFile:close()
  234. local passFile = io.open("/.EnderOS/.passInfo", "r")
  235. passContents = passFile:read()
  236. passFile:close()
  237. term.setTextColor(colors.white)
  238. if read() == userContents then
  239. term.setCursorPos(8,8)
  240. term.setTextColor(colors.lime)
  241. term.write("O")
  242. term.setTextColor(colors.white)
  243. term.setCursorPos(20,10)
  244. if read("*") == passContents then
  245. term.setCursorPos(8,10)
  246. term.setTextColor(colors.lime)
  247. term.write("O")
  248. term.setTextColor(colors.white)
  249. sleep(0.8)
  250. term.clear()
  251. term.setCursorPos(19,9)
  252. x,y = term.getCursorPos()
  253. print("Logging in")
  254. term.setCursorPos(x+10,9)
  255. sleep(0.7)
  256. print(".")
  257. sleep(0.7)
  258. term.setCursorPos(x+11,9)
  259. print(".")
  260. sleep(0.7)
  261. term.setCursorPos(x+12,9)
  262. print(".")
  263. sleep(0.7)
  264. reset()
  265. start()
  266. else
  267. term.setCursorPos(8,10)
  268. term.setTextColor(colors.red)
  269. term.write("X")
  270. sleep(0.5)
  271. term.setTextColor(colors.white)
  272. screen()
  273. login()
  274. end
  275. else
  276. term.setCursorPos(8,8)
  277. term.setTextColor(colors.red)
  278. term.write("X")
  279. sleep(0.5)
  280. term.setTextColor(colors.white)
  281. screen()
  282. login()
  283. end
  284. end
  285. function settings()
  286. term.setTextColor(colors.purple)
  287. frame()
  288. term.setCursorPos(17,1)
  289. term.setTextColor(colors.lime)
  290. print("[EnderOS Settings]")
  291. term.setCursorPos(7,3)
  292. print("{Change Username} {Change Password}")
  293. term.setCursorPos(15,5)
  294. print("{Change Password Hint}")
  295. term.setCursorPos(3,1)
  296. term.setTextColor(colors.orange)
  297. term.write("[Back]")
  298. term.setTextColor(colors.white)
  299. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  300. if button == 1 then
  301. if (xPos >=7 and xPos <=23 and yPos == 3) then
  302. settingsChangeUser()
  303. elseif (xPos >=27 and xPos <=43 and yPos == 3) then
  304. settingsChangePass()
  305. elseif (xPos >=15 and xPos <=36 and yPos == 5) then
  306. settingsChangeHint()
  307. elseif (xPos >=3 and xPos <=9 and yPos == 1) then
  308. start()
  309. else
  310. settings()
  311. end
  312. else
  313. sleep(1)--This is to prevent spamming, thus "overloading" EnderOS
  314. settings()
  315. end
  316. end
  317. function start()
  318. reset()
  319. term.setTextColor(colors.purple)
  320. frame()
  321. term.setCursorPos(3,19)
  322. term.setTextColor(colors.orange)
  323. term.write("[Log Out]")
  324. term.setCursorPos(17,1)
  325. term.setTextColor(colors.lime)
  326. print("[EnderOS Commands]")
  327. term.setCursorPos(3,3)
  328. print("{Settings} {Exit}")
  329. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  330. if button == 1 then
  331. if (xPos >=16 and xPos <=21 and yPos == 3) then
  332. reset()
  333. elseif (xPos >=3 and xPos <=12 and yPos == 3) then
  334. settings()
  335. elseif (xPos >=3 and xPos <=11 and yPos == 19) then
  336. reset()
  337. screen()
  338. login()
  339. else
  340. start()
  341. end
  342. else
  343. sleep(1)--This is to prevent spamming, thus "overloading" EnderOS
  344. start()
  345. end
  346. end
  347.  
  348.  
  349. --EnderOS
  350. os.pullEvent = os.pullEventRaw
  351. if not term.isColor() then
  352. term.clear()
  353. term.setCursorPos(1,1)
  354. print("EnderOS does not support non-color computers!")
  355. sleep(3)
  356. os.shutdown()
  357. end
  358. if not fs.exists("/.EnderOS/.EnderOSisInstalled") then
  359. userInfo()
  360. end
  361. reset()
  362. term.setTextColor(colors.purple)
  363. term.setCursorPos(13,7)
  364. print("EnderOS "..version.." Initializing")
  365. term.setTextColor(colors.white)
  366. term.setBackgroundColor(colors.lime)
  367. for i = 14,36 do
  368. term.setCursorPos(i,9)
  369. term.write(" ")
  370. sleep(0.3)
  371. end
  372. term.setBackgroundColor(colors.black)
  373. sleep(0.5)
  374. screen()
  375. login()
  376. start()
Advertisement
Add Comment
Please, Sign In to add comment