ComputerMan123

DelOS

Oct 8th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.59 KB | None | 0 0
  1.  
  2. os.pullEvent = os.pullEventRaw
  3.  
  4. term.clear()
  5. term.setCursorPos(1,1)
  6. local selection = 1;
  7. local version = "1.3.1";
  8. local path = "";
  9. local page = 1;
  10. local function cPrint(text)
  11. local x,y = term.getSize()
  12. local x2,y2 = term.getCursorPos()
  13. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  14. print(text)
  15. end
  16. local function cWrite(text)
  17. local x,y = term.getSize()
  18. local x2,y2 = term.getCursorPos()
  19. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  20. write(text)
  21. end
  22.  
  23. function dmenu()
  24. term.clear()
  25. term.setCursorPos(1,1)
  26. cPrint("---------------------")
  27. cPrint("DelOS v" ..version)
  28. cPrint("---------------------")
  29. print("Type 'Downloads' to view downloads.")
  30. print("Type 'Download' to download files.")
  31. command = read()
  32. if command == "Downloads" then
  33. path = "downloads"
  34. filemanager()
  35. elseif command == "Download" then
  36. term.clear()
  37. term.setCursorPos(1,1)
  38. cPrint("---------------------")
  39. cPrint("DelOS v" ..version)
  40. cPrint("---------------------")
  41. write("Please enter the file ID: ")
  42. code = read()
  43. write("Please enter the name: ")
  44. name = read()
  45. if fs.exists("downloads/" ..name) then
  46. write(name.. " already exists! Would you like to overwrite this file? ")
  47. option = read()
  48. if option == "Yes" then
  49. fs.delete("downloads/" ..name)
  50. shell.run("pastebin","get", code, "downloads/" ..name)
  51. sleep(2)
  52. dmenu()
  53. elseif option == "No" then
  54. print("Cancled...")
  55. sleep(2)
  56. dmenu()
  57. else
  58. print("Option does not exist! Say Yes or No.")
  59. sleep(2)
  60. dmenu()
  61. end
  62. else
  63. shell.run("pastebin","get", code, "downloads/" ..name)
  64. sleep(3)
  65. dmenu()
  66. end
  67. else
  68. print("Command does not exist!")
  69. sleep(2)
  70. dmenu()
  71. end
  72. end
  73. function BootOptions()
  74. term.clear()
  75. term.setCursorPos(1,1)
  76. cPrint("---------------------")
  77. cPrint("DelOS v" ..version)
  78. cPrint("---------------------")
  79. cPrint("")
  80. if page == 1 then
  81. if selection == 1 then
  82. cPrint("--> File Manager <--")
  83. else
  84. cPrint("File Manager")
  85. end
  86. if selection == 2 then
  87. cPrint("--> Internet <--")
  88. else
  89. cPrint("Internet")
  90. end
  91. if selection == 3 then
  92. cPrint("--> Download Manager <--")
  93. else
  94. cPrint("Download Manager")
  95. end
  96.  
  97. if selection == 4 then
  98. cPrint("--> Switch to monitor mode <--")
  99. else
  100. cPrint("Switch to monitor mode")
  101. end
  102.  
  103. if selection == 5 then
  104. cPrint("--> Lua mode <--")
  105. else
  106. cPrint("Lua mode")
  107. end
  108. elseif page == 2 then
  109. if selection == 1 then
  110. cPrint("--> Game Library <--")
  111. else
  112. cPrint("Game Library")
  113. end
  114. if selection == 2 then
  115. cPrint("--> Change Password <--")
  116. else
  117. cPrint("Change Password")
  118. end
  119. if selection == 3 then
  120. cPrint("--> Blank <--")
  121. else
  122. cPrint("Blank")
  123. end
  124.  
  125. if selection == 4 then
  126. cPrint("--> Blank <--")
  127. else
  128. cPrint("Blank")
  129. end
  130.  
  131. if selection == 5 then
  132. cPrint("--> Blank <--")
  133. else
  134. cPrint("Blank")
  135. end
  136. end
  137.  
  138. if selection == 6 then
  139. cPrint("--> Shutdown <--")
  140. else
  141. cPrint("Shutdown")
  142. end
  143.  
  144. print("")
  145. if page == 1 then
  146. cPrint("Page " ..page.. " of 2. -->")
  147. elseif page == 2 then
  148. cPrint("< -- Page " ..page.. " of 2")
  149. end
  150. end
  151.  
  152. function password()
  153. term.clear()
  154. term.setCursorPos(1,1)
  155. cPrint("---------------------")
  156. cPrint("DelOS v" ..version)
  157. cPrint("---------------------")
  158. cPrint("")
  159. if fs.exists("/.pass") then
  160. cWrite("Password: ")
  161. file = fs.open("/.pass","r")
  162. correctpass = file.readAll()
  163. file.close()
  164. pass = read("*")
  165. if pass == correctpass then
  166. term.clear()
  167. term.setCursorPos(1,1)
  168. print("Welcome!")
  169. sleep(2)
  170. BootOptions()
  171. else
  172. print("")
  173. write("Incorrect! Rebooting!")
  174. sleep(2)
  175. os.reboot()
  176. end
  177. else
  178. cPrint("No password set. Set one now.")
  179. cWrite("New password: ")
  180. newPass = read("*")
  181. cWrite("Comfirm Password: ")
  182. comPass = read("*")
  183. if newPass == comPass then
  184. file = fs.open("/.pass","w")
  185. file.write(newPass)
  186. file.close()
  187. print("Password set, rebooting...")
  188. sleep(2)
  189. os.reboot()
  190. else
  191. print("Password does not match comfirm.")
  192. sleep(2)
  193. password()
  194. end
  195. end
  196. end
  197.  
  198.  
  199. function Loader()
  200. cPrint("---------------------")
  201. cPrint("DelOS v" ..version)
  202. cPrint("---------------------")
  203. cPrint("")
  204. cPrint("Loading.")
  205. cPrint("[ ]")
  206. sleep(1)
  207. term.clear()
  208. term.setCursorPos(1,1)
  209. cPrint("---------------------")
  210. cPrint("DelOS v" ..version)
  211. cPrint("---------------------")
  212. cPrint("")
  213. cPrint("Loading.")
  214. cPrint("[II ]")
  215. sleep(1)
  216. term.clear()
  217. term.setCursorPos(1,1)
  218. cPrint("---------------------")
  219. cPrint("DelOS v" ..version)
  220. cPrint("---------------------")
  221. cPrint("")
  222. cPrint("Loading.")
  223. cPrint("[IIII ]")
  224. sleep(1)
  225. term.clear()
  226. term.setCursorPos(1,1)
  227. cPrint("---------------------")
  228. cPrint("DelOS v" ..version)
  229. cPrint("---------------------")
  230. cPrint("")
  231. cPrint("Loading.")
  232. cPrint("[IIIIII]")
  233. sleep(1)
  234. --BootOptions()
  235. password()
  236. end
  237.  
  238. Loader()
  239.  
  240. while true do
  241. local e,key = os.pullEvent( "key" )
  242. if key == 17 or key == 200 then
  243. if selection > 1 then
  244. selection = selection - 1
  245. BootOptions()
  246. end
  247. elseif key == 31 or key == 208 then
  248. if selection < 6 then
  249. selection = selection + 1
  250. BootOptions()
  251. end
  252. elseif key == 203 then
  253. if page > 1 then
  254. page = page - 1
  255. BootOptions()
  256. end
  257. elseif key == 205 then
  258. if page < 2 then
  259. page = page + 1
  260. BootOptions()
  261. end
  262. elseif key == 28 then
  263. if selection == 6 then
  264. os.shutdown()
  265. elseif selection > 2 and page == 2 then
  266. BootOptions()
  267. else
  268. break
  269. end
  270. end
  271. end
  272. function filemanager()
  273. term.clear()
  274. term.setCursorPos(1,1)
  275. cPrint("---------------------")
  276. cPrint("DelOS v" ..version)
  277. cPrint("C://" ..path)
  278. cPrint("---------------------")
  279. shell.run("dir", path)
  280. cPrint("---------------------")
  281. write("C://")
  282. directory = read()
  283. path = directory
  284. if fs.isDir( path ) then
  285. if path == "disk" then
  286. print("Browse or Label?")
  287. write("Do: ")
  288. command = read()
  289.  
  290. if command == "Browse" then
  291. filemanager()
  292. elseif command == "Label" then
  293. write("Choose a side: ")
  294. diskside = read()
  295. write("Enter what you want to label it: ")
  296. diskname = read()
  297. shell.run("label", "set", diskside, diskname)
  298. print("Labeled!")
  299. sleep(1)
  300. path = ""
  301. filemanager()
  302. else
  303. print("Invalid Command!")
  304. sleep(1)
  305. path = ""
  306. filemanager()
  307. end
  308. else
  309. filemanager()
  310. end
  311. else
  312. term.clear()
  313. term.setCursorPos(1,1)
  314. cPrint("---------------------")
  315. cPrint("DelOS v" ..version)
  316. cPrint("---------------------")
  317. print("Run, Copy, Delete, Edit, Move, or Upload?")
  318. write("Do: ")
  319. command = read()
  320.  
  321. if command == "Run" then
  322. shell.run(path)
  323. elseif command == "Copy" then
  324. write("Copy to where?")
  325. copypath = read()
  326. fs.copy(path, copypath)
  327. print("Copied!")
  328. sleep(1)
  329. path = ""
  330. filemanager()
  331. elseif command == "Delete" then
  332. print("Deleted.")
  333. fs.delete(path)
  334. sleep(1)
  335. path = ""
  336. filemanager()
  337. elseif command == "Upload" then
  338. shell.run("pastebin","put", path)
  339. sleep(5)
  340. path = ""
  341. filemanager()
  342. elseif command == "Move" then
  343. write("Move where?")
  344. movepath = read()
  345. fs.move(path, movepath)
  346. print("Moved!")
  347. sleep(3)
  348. path = ""
  349. filemanager()
  350. elseif command == "Edit" then
  351. shell.run("edit", path)
  352. else
  353. print("Command does not exist.")
  354. sleep(1)
  355. path = ""
  356. filemanager()
  357. end
  358. end
  359. end
  360.  
  361. function games()
  362. term.clear()
  363. term.setCursorPos(1,1)
  364. cPrint("---------------------")
  365. cPrint("DelOS v" ..version)
  366. cPrint("---------------------")
  367. cPrint("Game Library: ")
  368. if fs.exists("games") then
  369. shell.run("dir", "games")
  370. else
  371. fs.makeDir("games")
  372. fs.copy("rom/programs/computer/worm", "games/Worm")
  373. shell.run("dir", "games")
  374. end
  375. write("C://games/")
  376. input = read()
  377. if fs.exists("games/"..input) then
  378. shell.run("games/" ..input)
  379. else
  380. print("This game does not exist, would you like to download it (y/n)?")
  381. input = read()
  382. if input == "n" then
  383. games()
  384. elseif input == "y" then
  385. write("Enter the pastebin game ID: ")
  386. fileid = read()
  387. write("Enter the game name: ")
  388. filename = read()
  389. shell.run("pastebin", "get", fileid, "games/" ..filename)
  390. games()
  391. else
  392. print("Unknown...")
  393. sleep(3)
  394. games()
  395. end
  396. end
  397. end
  398.  
  399.  
  400. function password()
  401. term.clear()
  402. term.setCursorPos(1,1)
  403. cPrint("---------------------")
  404. cPrint("DelOS v" ..version)
  405. cPrint("---------------------")
  406. cPrint("")
  407. cWrite("Old Password: ")
  408. file = fs.open("/.pass","r")
  409. correctpass = file.readAll()
  410. file.close()
  411. pass = read("*")
  412. if pass == correctpass then
  413. cWrite("New Password: ")
  414. oldpass = read("*")
  415. fs.delete("/.pass")
  416.  
  417. else
  418. print("")
  419. write("Incorrect! Rebooting!")
  420. sleep(2)
  421. os.reboot()
  422. end
  423. end
  424.  
  425. if page == 1 then
  426. if selection == 1 then
  427. if fs.exists("movies") then
  428. else
  429. fs.makeDir("movies")
  430. fs.copy("rom/programs/secret/alongtimeago", "movies/starwars")
  431. end
  432. term.clear()
  433. term.setCursorPos(1,1)
  434. cPrint("---------------------")
  435. cPrint("DelOS v" ..version)
  436. cPrint("C://" ..path)
  437. cPrint("---------------------")
  438. shell.run("dir", path)
  439. cPrint("---------------------")
  440. write("C://")
  441. directory = read()
  442. path = directory
  443. if fs.isDir( path ) then
  444. if path == "disk" then
  445. print("Browse or Label?")
  446. write("Do: ")
  447. command = read()
  448.  
  449. if command == "Browse" then
  450. filemanager()
  451. elseif command == "Label" then
  452. write("Choose a side: ")
  453. diskside = read()
  454. write("Enter what you want to label it: ")
  455. diskname = read()
  456. shell.run("label", "set", diskside, diskname)
  457. print("Labeled!")
  458. sleep(1)
  459. path = ""
  460. filemanager()
  461. else
  462. print("Invalid Command!")
  463. sleep(1)
  464. path = ""
  465. filemanager()
  466. end
  467. else
  468. filemanager()
  469. end
  470. else
  471. term.clear()
  472. term.setCursorPos(1,1)
  473. cPrint("---------------------")
  474. cPrint("DelOS v" ..version)
  475. cPrint("---------------------")
  476. print("Run, Copy, Delete, Edit, Move, or Upload?")
  477. write("Do: ")
  478. command = read()
  479.  
  480. if command == "Run" then
  481. shell.run(path)
  482. elseif command == "Copy" then
  483. write("Copy to where?")
  484. copypath = read()
  485. fs.copy(path, copypath)
  486. print("Copied!")
  487. sleep(1)
  488. path = ""
  489. filemanager()
  490. elseif command == "Delete" then
  491. print("Deleted.")
  492. fs.delete(path)
  493. sleep(1)
  494. path = ""
  495. filemanager()
  496. elseif command == "Upload" then
  497. shell.run("pastebin","put", path)
  498. sleep(5)
  499. path = ""
  500. filemanager()
  501. elseif command == "Move" then
  502. write("Move where?")
  503. movepath = read()
  504. fs.move(path, movepath)
  505. print("Moved!")
  506. sleep(3)
  507. path = ""
  508. filemanager()
  509. elseif command == "Edit" then
  510. shell.run("edit", path)
  511. else
  512. print("Command does not exist.")
  513. sleep(1)
  514. path = ""
  515. filemanager()
  516. end
  517. end
  518. end
  519. if selection == 2 then
  520. if fs.exists("rn") then
  521. shell.run("rn")
  522. else
  523. shell.run("pastebin","get","Y320Z2K0","rn")
  524. shell.run("rn")
  525. end
  526. end
  527. if selection == 4 then
  528. term.clear()
  529. term.setCursorPos(1,1)
  530. cPrint("---------------------")
  531. cPrint("DelOS v" ..version)
  532. cPrint("---------------------")
  533. print("Please choose a monitor side (left or right?): ")
  534. monitorside = read()
  535. term.clear()
  536. term.setCursorPos(1,1)
  537. cPrint("---------------------")
  538. cPrint("DelOS v" ..version)
  539. cPrint("---------------------")
  540. shell.run("monitor", monitorside, "startup")
  541. end
  542.  
  543. if selection == 5 then
  544. term.clear()
  545. term.setCursorPos(1,1)
  546. cPrint("---------------------")
  547. cPrint("DelOS v" ..version)
  548. cPrint("---------------------")
  549. if fs.exists("newluacode") then
  550. shell.run("newluacode")
  551. else
  552. shell.run("pastebin", "get", "emFiR2kK", "newluacode")
  553. term.clear()
  554. term.setCursorPos(1,1)
  555. cPrint("---------------------")
  556. cPrint("DelOS v" ..version)
  557. cPrint("---------------------")
  558. shell.run("newluacode")
  559. end
  560. end
  561.  
  562. if selection == 3 then
  563. if fs.exists("downloads") then
  564. else
  565. fs.makeDir("downloads")
  566. end
  567. dmenu()
  568. end
  569. elseif page == 2 then
  570. if selection == 1 then
  571. games()
  572. end
  573.  
  574. if selection == 2 then
  575. cPrint("---------------------")
  576. cPrint("DelOS v" ..version)
  577. cPrint("---------------------/n")
  578. cWrite("Old password: ")
  579. newPass = read("*")
  580. file = fs.open("/.pass","r")
  581. correctpass = file.readAll()
  582. file.close()
  583. if newPass == correctpass then
  584. cWrite("New password: ")
  585. comPass = read("*")
  586. fs.delete("/.pass")
  587. file = fs.open("/.pass","w")
  588. file.write(newPass)
  589. file.close()
  590. cPrint("Password set! Rebooting")
  591. sleep(2)
  592. os.reboot()
  593. else
  594. cPrint("Incorrect password!")
  595. sleep(2)
  596. os.reboot()
  597. end
  598. end
  599. end
Add Comment
Please, Sign In to add comment