JustDoesGames

Turtos V2 Beta

May 7th, 2019
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.32 KB | None | 0 0
  1. --[[ TURTOS V2 ]]--
  2. --[[ Created by - Just Does Games ]]--
  3. --[[ Date of Creation - 5/6/2019 8:40PM ]]--
  4. --[[ Current Version - 1.0.0 ]]--
  5. local version = "V1_0_4"
  6. shell.run("cd /")
  7.  
  8. -- Initial Settup --
  9.  
  10. local sx,sy = term.getSize()
  11. local files = {"MenuAPI"}
  12. local links = {"1RAWvWp2"}
  13.  
  14. if sx ~= 51 and sy ~= 19 then
  15.     term.setTextColor(colors["black"])
  16.     for i=1, #files do
  17.         if not fs.exists(files[i]) then
  18.             shell.run("pastebin get "..links[i].." "..files[i])
  19.             if not fs.exists(files[i]) then
  20.                 term.setTextColor(colors["white"]) print("Connection to pastebin failed!") sleep(.1) return
  21.             end
  22.         end
  23.     end
  24.     term.setTextColor(colors["white"])
  25. end
  26.  
  27. -- Initial Settup --
  28.  
  29. -- Functions --
  30.  
  31. function clr() term.clear() end
  32. function cp(x,y) term.setCursorPos(x,y) end
  33. function sb(col) term.setBackgroundColor(colors[col]) end
  34. function st(col) term.setTextColor(colors[col]) end
  35.  
  36. -- Functions --
  37.  
  38. -- Main sections --
  39.  
  40. function main()
  41.     update()
  42.     local menu_0 = {"Regular Tunnel", "Manual Control", "3 by 1 Tunnel", "Exit"} local running = true
  43.     while running do
  44.         local tmp = MenuAPI.run(menu_0)
  45.         if tmp == 1 then
  46.             clr() cp(1,1) write("Distance: ") local tmp = tonumber(read())
  47.             if type(tmp) == "number" then
  48.                 regularTunnel(tmp)
  49.             end
  50.         elseif tmp == 2 then
  51.             manualControl()
  52.         elseif tmp == 3 then
  53.             clr() cp(1,1) write("Distance: ") local tmp = tonumber(read())
  54.             if type(tmp) == "number" then
  55.                 tboTunnel(tmp)
  56.             end
  57.         elseif tmp == #menu_0 then
  58.             os.shutdown()
  59.         end
  60.     end
  61. end
  62.  
  63. function regularTunnel(dis)
  64.     clr()
  65.     cp(1,1)
  66.     print("Tunneling for "..dis.." Block(s) long")
  67.     sleep(.5)
  68.     shell.run("tunnel "..dis)
  69.     sleep(.01)
  70.     for i=1, 2 do turtle.turnLeft() sleep(.01) end
  71.     turtle.up()
  72.     repeat
  73.         turtle.digUp()
  74.         sleep(.2)
  75.     until turtle.detect() == false
  76.     turtle.up()
  77.     sleep(.01)
  78.     shell.run("tunnel "..dis)
  79.     for i=1, 2 do turtle.turnLeft() sleep(.01) end
  80.     for i=1, 2 do turtle.down() sleep(.01) end
  81. end
  82.  
  83. function manualControl()
  84.     local menu_0 = {"Forward", "Backwards", "Up", "Down", "Rotate Left", "Rotate Right", "Dig Forward", "Dig Up", "Dig Down", "Fuel Level: "..turtle.getFuelLevel(), "Exit"} local running = true MenuAPI.resetPosition(false)
  85.     while running do
  86.         fuelCheck()
  87.         menu_0[#menu_0-1] = "Fuel Level: "..turtle.getFuelLevel() local tmp = MenuAPI.run(menu_0)
  88.         if tmp == 1 then
  89.             turtle.forward()
  90.         elseif tmp == 2 then
  91.             turtle.back()
  92.         elseif tmp == 3 then
  93.             turtle.up()
  94.         elseif tmp == 4 then
  95.             turtle.down()
  96.         elseif tmp == 5 then
  97.             turtle.turnLeft()
  98.         elseif tmp == 6 then
  99.             turtle.turnRight()
  100.         elseif tmp == 7 then
  101.             turtle.dig()
  102.         elseif tmp == 8 then
  103.             turtle.digUp()
  104.         elseif tmp == 9 then
  105.             turtle.digDown()
  106.         elseif tmp == 10 then
  107.             -- do nothing
  108.         elseif tmp == #menu_0 then
  109.             running = false
  110.         end
  111.     end MenuAPI.resetPosition(true)
  112. end
  113.  
  114. function tboTunnel(dis)
  115.     clr()
  116.     cp(1,1)
  117.     print("Tunneling for "..dis.." Block(s) long")
  118.     sleep(.5)
  119.     for i=1, dis do
  120.         turtle.turnRight()
  121.         repeat
  122.             turtle.dig()
  123.             sleep(.1)
  124.         until turtle.detect() == false
  125.         for i=1, 2 do turtle.turnLeft() sleep(.1) end
  126.         repeat
  127.             turtle.dig()
  128.             sleep(.1)
  129.         until turtle.detect() == false
  130.         turtle.turnRight()
  131.         repeat
  132.             turtle.dig()
  133.             sleep(.2)
  134.         until turtle.detect() == false
  135.         fuelCheck()
  136.         turtle.forward()
  137.     end
  138.     for i=1, dis do
  139.         turtle.back()
  140.     end
  141. end
  142.  
  143. function fuelCheck()
  144.     if turtle.getFuelLevel() == 0 then
  145.         clr() cp(1,1) print("Needs more fuel!")
  146.         repeat
  147.             turtle.refuel(1)
  148.             sleep(.1)
  149.         until turtle.getFuelLevel() ~= 0
  150.     end
  151. end
  152.  
  153. function install()
  154.     local menu_0 = {"Install", "Uninstall", "Update", "Shell", "Exit"} local running = true
  155.     while running do
  156.         local tmp = MenuAPI.run(menu_0)
  157.         if tmp == 1 then
  158.             if fs.exists("startup") then fs.delete("startup") end fs.copy(shell.getRunningProgram(), "startup") if not fs.exists(version.."/main") then fs.copy(shell.getRunningProgram(), version.."/main") end shell.run("label set Turtos") clr() cp(1,1) print("Install Complete!") sleep(1) os.shutdown()
  159.         elseif tmp == 2 then
  160.             for i=1, #files do
  161.                 fs.delete(files[i])
  162.             end
  163.             fs.delete("startup") shell.run("label clear") clr() cp(1,1) print("Uninstall Complete!") sleep(1) os.shutdown()
  164.         elseif tmp == 3 then
  165.             for i=1, #files do
  166.                 fs.delete(files[i])
  167.             end fs.delete("startup")
  168.             fs.copy(shell.getRunningProgram(), "startup") if not fs.exists(version.."/main") then fs.copy(shell.getRunningProgram(), version.."/main") end clr() cp(1,1) print("Update Complete!") sleep(1) os.shutdown()
  169.         elseif tmp == 4 then
  170.             clr() cp(1,1) return true
  171.         elseif tmp == #menu_0 then
  172.             os.shutdown()
  173.         end
  174.     end
  175. end
  176.  
  177. function update()
  178.     shell.run("pastebin run GNQ0iwtG")
  179. end
  180.  
  181. os.loadAPI("MenuAPI")
  182. if sx ~= 51 and sy ~= 19 then
  183.     -- Must be a turtle or another device
  184.     if sx == 39 and sy == 13 then
  185.         if shell.getRunningProgram() == "disk/startup" or shell.getRunningProgram() == "disk/startup.lua" then
  186.             install()
  187.         else
  188.             main() -- has to be a turtle
  189.         end
  190.     end
  191. else
  192.     -- a regular computer
  193.     clr() cp(1,1) print("Turtos disk skipped! Regular computer detected.")
  194. end
  195.  
  196. -- Main sections --
Advertisement
Add Comment
Please, Sign In to add comment