Advertisement
Klazam33

MasterShell

Apr 4th, 2013 (edited)
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.97 KB | None | 0 0
  1. if not fs.exists("kapi") then
  2.  shell.run("label set KlazTurtle")
  3.  shell.run("pastebin get Wa30xjVY kapi")
  4.  shell.run("pastebin get 4wViUFbv MineShaft")
  5.  shell.run("pastebin get Ybfk4mFM HyperRefuel")
  6.  shell.run("pastebin get 42ZuYW7f TreeFarm")
  7.  os.loadAPI("kapi")
  8. else
  9.  os.loadAPI("kapi")
  10. end
  11.  
  12. --Table of options
  13. option = {"MineShaft", "HyperRefuel", "TreeFarm", "Advanced Options"}
  14. advOption = {"Update All", "Update API", "Update Installer", "Reformat Turtle", "Exit"}
  15.  
  16. --Variables
  17. l = #option
  18. vl = #advOption
  19. n = 1 --For Option Table
  20. o = 1 --For advOption Table
  21.  
  22. while true do
  23.  
  24.  kapi.menu("Please select a program from the following:")
  25.  for i = 1, l, 1 do
  26.   if n == i then
  27.    print(">" .. option[i] .. "<")
  28.   else
  29.    print(" " .. option[i])
  30.   end
  31.  end
  32.  
  33.  keypress = kapi.keyread()
  34.  if keypress == keys.up then --Up Arrow
  35.   if n == 1 then
  36.    n = l
  37.   else
  38.    n = n - 1
  39.   end
  40.  elseif keypress == keys.down then --Down Arrow
  41.   if n == l then
  42.    n = 1
  43.   else
  44.    n = n + 1
  45.   end
  46.  elseif keypress == keys.enter then --Enter key
  47.   kapi.clear()
  48.   if option[n] == "Advanced Options" then
  49.    while true do
  50.     kapi.menu("Select one of the following options.")
  51.     for i = 1, vl, 1 do
  52.      if o == i then
  53.       print(">" .. advOption[i] .. "<")
  54.      else
  55.       print(" " .. advOption[i])
  56.      end
  57.     end
  58.     keypress = kapi.keyread()
  59.     if keypress == keys.up then --Up Arrow
  60.      if o == 1 then
  61.       o = al
  62.      else
  63.       o = o - 1
  64.      end
  65.     elseif keypress == keys.down then --Down Arrow
  66.      if o == al then
  67.       o = 1
  68.      else
  69.       o = o + 1
  70.      end
  71.     elseif keypress == keys.enter then --Enter key    
  72.      if advOption[o] == "Update All" then
  73.       shell.run("delete MineShaft")
  74.       shell.run("delete HyperRefuel")
  75.       shell.run("delete TreeFarm")
  76.       print("Old versions deleted. Updating now.")
  77.       shell.run("pastebin get 4wViUFbv MineShaft")
  78.       shell.run("pastebin get Ybfk4mFM HyperRefuel")
  79.       shell.run("pastebin get 42ZuYW7f TreeFarm")
  80.       print("Update done! Press Enter to return to main menu.")
  81.       kapi.rawread(keys.enter)
  82.      elseif advOption[o] == "Update API" then
  83.       shell.run("delete kapi")
  84.       print("Old API deleted.")
  85.       shell.run("pastebin get Wa30xjVY kapi")
  86.       print("Update done! Press Enter to return to main menu.")
  87.       kapi.rawread(keys.enter)
  88.      elseif advOption[o] == "Update Installer" then
  89.       print("Deleting old Installer")
  90.       shell.run("delete startup")
  91.       shell.run("pastebin get aWFTCV3M startup")
  92.       print("Installer updated! Press Enter to reboot.")
  93.       kapi.rawread(keys.enter)
  94.       os.reboot()
  95.      elseif advOption[o] == "Reformat Turtle" then      
  96.       shell.run("label clear")
  97.       print("IF YOU DONT WANT TO LOSE FUEL, RELABEL BEFORE BREAKING")
  98.       kapi.rawread(keys.enter)
  99.       os.reboot()
  100.      elseif advOption[o] == "Exit" then
  101.       break
  102.      else
  103.      end
  104.     end
  105.    end
  106.   else
  107.    shell.run(option[n])
  108.   end
  109.  end
  110. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement