Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ TURTOS V2 ]]--
- --[[ Created by - Just Does Games ]]--
- --[[ Date of Creation - 5/6/2019 8:40PM ]]--
- --[[ Current Version - 1.0.0 ]]--
- local version = "V1_0_4"
- shell.run("cd /")
- -- Initial Settup --
- local sx,sy = term.getSize()
- local files = {"MenuAPI"}
- local links = {"1RAWvWp2"}
- if sx ~= 51 and sy ~= 19 then
- term.setTextColor(colors["black"])
- for i=1, #files do
- if not fs.exists(files[i]) then
- shell.run("pastebin get "..links[i].." "..files[i])
- if not fs.exists(files[i]) then
- term.setTextColor(colors["white"]) print("Connection to pastebin failed!") sleep(.1) return
- end
- end
- end
- term.setTextColor(colors["white"])
- end
- -- Initial Settup --
- -- Functions --
- function clr() term.clear() end
- function cp(x,y) term.setCursorPos(x,y) end
- function sb(col) term.setBackgroundColor(colors[col]) end
- function st(col) term.setTextColor(colors[col]) end
- -- Functions --
- -- Main sections --
- function main()
- update()
- local menu_0 = {"Regular Tunnel", "Manual Control", "3 by 1 Tunnel", "Exit"} local running = true
- while running do
- local tmp = MenuAPI.run(menu_0)
- if tmp == 1 then
- clr() cp(1,1) write("Distance: ") local tmp = tonumber(read())
- if type(tmp) == "number" then
- regularTunnel(tmp)
- end
- elseif tmp == 2 then
- manualControl()
- elseif tmp == 3 then
- clr() cp(1,1) write("Distance: ") local tmp = tonumber(read())
- if type(tmp) == "number" then
- tboTunnel(tmp)
- end
- elseif tmp == #menu_0 then
- os.shutdown()
- end
- end
- end
- function regularTunnel(dis)
- clr()
- cp(1,1)
- print("Tunneling for "..dis.." Block(s) long")
- sleep(.5)
- shell.run("tunnel "..dis)
- sleep(.01)
- for i=1, 2 do turtle.turnLeft() sleep(.01) end
- turtle.up()
- repeat
- turtle.digUp()
- sleep(.2)
- until turtle.detect() == false
- turtle.up()
- sleep(.01)
- shell.run("tunnel "..dis)
- for i=1, 2 do turtle.turnLeft() sleep(.01) end
- for i=1, 2 do turtle.down() sleep(.01) end
- end
- function manualControl()
- 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)
- while running do
- fuelCheck()
- menu_0[#menu_0-1] = "Fuel Level: "..turtle.getFuelLevel() local tmp = MenuAPI.run(menu_0)
- if tmp == 1 then
- turtle.forward()
- elseif tmp == 2 then
- turtle.back()
- elseif tmp == 3 then
- turtle.up()
- elseif tmp == 4 then
- turtle.down()
- elseif tmp == 5 then
- turtle.turnLeft()
- elseif tmp == 6 then
- turtle.turnRight()
- elseif tmp == 7 then
- turtle.dig()
- elseif tmp == 8 then
- turtle.digUp()
- elseif tmp == 9 then
- turtle.digDown()
- elseif tmp == 10 then
- -- do nothing
- elseif tmp == #menu_0 then
- running = false
- end
- end MenuAPI.resetPosition(true)
- end
- function tboTunnel(dis)
- clr()
- cp(1,1)
- print("Tunneling for "..dis.." Block(s) long")
- sleep(.5)
- for i=1, dis do
- turtle.turnRight()
- repeat
- turtle.dig()
- sleep(.1)
- until turtle.detect() == false
- for i=1, 2 do turtle.turnLeft() sleep(.1) end
- repeat
- turtle.dig()
- sleep(.1)
- until turtle.detect() == false
- turtle.turnRight()
- repeat
- turtle.dig()
- sleep(.2)
- until turtle.detect() == false
- fuelCheck()
- turtle.forward()
- end
- for i=1, dis do
- turtle.back()
- end
- end
- function fuelCheck()
- if turtle.getFuelLevel() == 0 then
- clr() cp(1,1) print("Needs more fuel!")
- repeat
- turtle.refuel(1)
- sleep(.1)
- until turtle.getFuelLevel() ~= 0
- end
- end
- function install()
- local menu_0 = {"Install", "Uninstall", "Update", "Shell", "Exit"} local running = true
- while running do
- local tmp = MenuAPI.run(menu_0)
- if tmp == 1 then
- 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()
- elseif tmp == 2 then
- for i=1, #files do
- fs.delete(files[i])
- end
- fs.delete("startup") shell.run("label clear") clr() cp(1,1) print("Uninstall Complete!") sleep(1) os.shutdown()
- elseif tmp == 3 then
- for i=1, #files do
- fs.delete(files[i])
- end fs.delete("startup")
- 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()
- elseif tmp == 4 then
- clr() cp(1,1) return true
- elseif tmp == #menu_0 then
- os.shutdown()
- end
- end
- end
- function update()
- shell.run("pastebin run GNQ0iwtG")
- end
- os.loadAPI("MenuAPI")
- if sx ~= 51 and sy ~= 19 then
- -- Must be a turtle or another device
- if sx == 39 and sy == 13 then
- if shell.getRunningProgram() == "disk/startup" or shell.getRunningProgram() == "disk/startup.lua" then
- install()
- else
- main() -- has to be a turtle
- end
- end
- else
- -- a regular computer
- clr() cp(1,1) print("Turtos disk skipped! Regular computer detected.")
- end
- -- Main sections --
Advertisement
Add Comment
Please, Sign In to add comment