star_weaver

Untitled

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