Computer_Craft_Coder

Clean Boot (Disk) (LUA)

Sep 18th, 2013
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.13 KB | None | 0 0
  1. local termWidth, termHeight = term.getSize()
  2. local selectedItem = 1
  3. local onMainMenu = true
  4.  
  5. function CleanBoot()
  6. term.clear()
  7. term.setCursorPos(1,1)
  8. print("Clean Boot Selected")
  9. print("Starting a Clean Startup File")
  10. textutils.slowPrint("All Threat's Are
  11. Successfuly Gone!")
  12. sleep(2)
  13. onMainMenu = false
  14. end
  15. function load()
  16. print("Recompiling File's.")
  17. sleep(1)
  18. term.clear()
  19. term.setCursorPos(1, 1)
  20. print("Recompiling File's..")
  21. sleep(1)
  22. term.clear()
  23. term.setCursorPos(1, 1)
  24. print("Recompiling File's...")
  25. sleep(1)
  26. term.clear()
  27. term.setCursorPos(1, 1)
  28. print("Recompiling File's..")
  29. sleep(1)
  30. term.clear()
  31. term.setCursorPos(1, 1)
  32. print("Recompiling File's.")
  33. sleep(1)
  34. term.clear()
  35. term.setCursorPos(1, 1)
  36. print("Recompiling File's..")
  37. sleep(1)
  38. term.clear()
  39. term.setCursorPos(1, 1)
  40. print("Recompiling File's...")
  41. sleep(1)
  42. term.clear()
  43. term.setCursorPos(1, 1)
  44. print("Recompiling File's..")
  45. sleep(1)
  46. term.clear()
  47. term.setCursorPos(1, 1)
  48. print("Recompiling File's.")
  49. sleep(1)
  50. term.clear()
  51. term.setCursorPos(1, 1)
  52. fs.delete("startup")
  53. print("All Modified Startup's Are Gone")
  54. sleep(2)
  55. end
  56. function checkFiles()
  57. term.clear()
  58. term.setCursorPos(1,1)
  59. load()
  60. end
  61. function Exit()
  62. onMainMenu = false
  63. end
  64.  
  65. mainMenu = {
  66. [1] = { text = "Clean Boot (Use After
  67. Recompiling)", handler = CleanBoot },
  68. [2] = { text = "Recompile", handler = checkFiles
  69. },
  70. [3] = { text = "Exit", handler = Exit }
  71. }
  72.  
  73. function printMenu( menu )
  74. for i=1,#menu do
  75.   if i == selectedItem then
  76.    print(">> "..menu[i].text)
  77.   else
  78.    print("   "..menu[i].text)
  79.   end
  80. end
  81. end
  82.  
  83. function onKeyPressed( key, menu )
  84. if key == keys.enter then
  85.   onItemSelected(menu)
  86. elseif key == keys.up then
  87.   if selectedItem > 1 then
  88.    selectedItem = selectedItem - 1
  89.   end
  90. elseif key == keys.down then
  91.   if selectedItem < #menu then
  92.    selectedItem = selectedItem + 1
  93.   end
  94. end
  95. end
  96.  
  97. function onItemSelected( menu )
  98. menu[selectedItem].handler()
  99. end
  100.  
  101. function main()
  102. while onMainMenu do
  103.   term.clear()
  104.   term.setCursorPos(1,1)
  105.   printMenu(mainMenu)
  106.   event, key = os.pullEvent("key")
  107.   onKeyPressed(key,mainMenu)
  108. end
  109. end
  110.  
  111. main()
Add Comment
Please, Sign In to add comment