Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local version = "v1_0_6"
- local version_raw = "v1.0.6"
- local clr = function() term.clear() end
- local setText = function(col) term.setTextColor(colors[col]) end
- local setBack = function(col) term.setBackColor(colors[col]) end
- local cp = function(x,y) term.setCursorPos(x,y) end
- local sx,sy = term.getSize()
- local running = true
- local selected = 1
- local m_0 = {"Turle Programs", "Options (Comming Soon!)", "Lua", "Restart"}
- local m_0_status = {true, false, true, true}
- local m_1 = {"Normal Tunnel", "Tunnel v2.0", "Tunnel Down", "3x1 Tunnel", "Manual Control", "Back"}
- local m_1_status = {true, false, true, true, false, true}
- local c_menu = m_0
- local c_menu_status = m_0_status
- local updat = true
- function main()
- if fs.exists(version) == false or version == "beta" then
- if version ~= "beta" then
- fs.makeDir(version)
- end
- PN()
- end
- while running do
- if updat == true or updat == nil then
- drawScreen()
- end
- cp(1,1)
- print("TURTOS "..version_raw.." ")
- for i=1, #c_menu do
- cp(3,i+2)
- if i == selected then
- setText("white")
- write("> ")
- if c_menu_status[selected] == false then
- setText("gray")
- else
- setText("white") -- IMPORTANT
- end
- write(c_menu[i])
- setText("white")
- print(" <")
- else
- setText("gray")
- print(" ", c_menu[i], " ")
- setText("white")
- end
- end
- a,i = os.pullEvent("key")
- if i == keys.w or i == keys.up then
- if selected ~= 1 then selected = selected - 1 end
- elseif i == keys.s or i == keys.down then
- if selected ~= #c_menu then selected = selected + 1 end
- elseif i == keys.e or i == keys.enter then
- if selected == #c_menu then
- if c_menu == m_0 then
- os.shutdown()
- else
- c_menu = m_0
- end
- selected = 1
- c_menu_status = m_0_status
- elseif c_menu == m_0 then
- if selected == 1 then
- c_menu = m_1
- c_menu_status = m_1_status
- selected = 1
- elseif selected == 2 then
- --
- elseif selected == 3 then
- clr()
- cp(1,1)
- running = false
- end
- elseif c_menu == m_1 then
- pre_tunnel(selected)
- end
- end
- end
- end
- function drawScreen()
- clr()
- cp(1,1)
- for i=1, sx do
- write("@") -- IMPORTANT
- end
- cp(1,sy)
- for i=1, sx do
- write("@") -- IMPORTANT
- end
- for i=1, sy-2 do
- cp(1,i+1)
- write("@") -- IMPORTANT
- end
- for i=1, sy-2 do
- cp(sx,i+1)
- write("@") -- IMPORTANT
- end
- end
- function fuelCheck()
- if turtle.getFuelLevel() == 0 then
- print("Needs More Fuel! Feed Me!!!")
- repeat
- turtle.refuel(1)
- sleep(.1)
- until turtle.getFuelLevel() ~= 0
- if turtle.getFuelLevel() ~= 0 then
- print("OM NOM NOM. FUAL MAKE ME STRONG AGAIN!")
- print("You feed me "..turtle.getFuelLevel().." Units!")
- end
- end
- end
- function pre_tunnel(select)
- if select == 5 then
- --turtle_manual()
- else
- drawScreen()
- cp(3,3)
- write("Distance: ")
- inp = tonumber(read())
- if type(inp) == "number" then
- if select == 1 then
- tunnel(inp)
- elseif select == 2 then
- tunnel_2(inp)
- elseif select == 3 then
- tunnel_down(inp)
- elseif select == 4 then
- tunnel_3x1(inp)
- end
- else
- cp(3,4)
- print("Distance was not a number or invalid!")
- sleep(1)
- end
- end
- end
- function tunnel(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 tunnel_2(dis)
- clr()
- cp(1,1)
- print("Tunneling for "..dis.." Block(s) long")
- sleep(.5)
- for i=1, dis do
- turtle.turnRight()
- for i=1, 4 do
- if i ~= 4 then
- repeat
- turtle.digUp()
- sleep(.1)
- until turtle.detectUp() == false
- end
- repeat
- turtle.dig()
- sleep(.1)
- until turtle.detect() == false
- fuelCheck()
- if 1 ~= 4 then
- turtle.up()
- end
- end
- for i=1, 2 do turtle.turnLeft() sleep(.01) end
- for i=1, 4 do
- repeat
- turtle.dig()
- sleep(.1)
- until turtle.detect() == false
- fuelCheck()
- if i ~= 4 then
- turtle.down()
- end
- end
- turtle.turnRight()
- if i ~= dis then
- repeat
- turtle.dig()
- sleep(.2)
- until turtle.detect() == false
- turtle.forward()
- end
- end
- for i=1, dis-1 do
- turtle.back()
- end
- for i=1, 3 do turtle.down() sleep(.01) end
- end
- function tunnel_down(dis)
- clr()
- cp(1,1)
- print("Tunneling for "..dis.." Block(s) long")
- sleep(.5)
- for i=1, dis do
- turtle.digDown()
- fuelCheck()
- if dis ~= 1 then
- turtle.down()
- end
- end
- for i=1, dis do
- fuelCheck()
- if dis ~= 1 then
- turtle.up()
- end
- end
- end
- function tunnel_3x1(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
- turtle.forward()
- end
- for i=1, dis do
- turtle.back()
- end
- end
- function turtle_manual()
- local runin = true
- clr()
- cp(1,1)
- local direct = "forward"
- print("'wasd' or arrow keys will work")
- print("'e' or enter to break or destroy")
- print("'q' to exit")
- print("")
- print("")
- print("q w e .")
- print(" a s d . . .")
- while runin do
- local a,i,z = os.pullEvent("key")
- if i == keys.w or i == keys.up and z == true then
- if direct ~= "forward" then
- if direct == "right" then
- turtle.turnLeft()
- direct = "forward"
- else
- turtle.turnRight()
- if direct == "back" then direct = "right" else direct = "forward" end
- end
- else
- turtle.forward()
- end
- elseif i == keys.s or i == keys.down and z == true then
- if direct ~= "back" then
- if direct == "right" then
- turtle.turnLeft()
- direct = "back"
- else
- turtle.turnRight()
- if direct == "back" then direct = "right" else direct = "forward" end
- end
- else
- turtle.forward()
- end
- elseif i == keys.d or i == keys.right and z == true then
- if direct ~= "right" then
- if direct == "forward" then
- turtle.turnRight()
- direct = "right"
- else
- turtle.turnLeft()
- if direct == "back" then direct = "left" else direct = "right" end
- end
- else
- turtle.forward()
- end
- elseif i == keys.a or i == keys.left and z == true then
- if direct ~= "left" then
- if direct == "forward" then
- turtle.turnLeft()
- direct = "left"
- else
- turtle.turnRight()
- if direct == "back" then direct = "left" else direct = "right" end
- end
- else
- turtle.forward()
- end
- elseif i == keys.e or i == keys.enter and z == true then
- if turtle.detect() == true then
- turtle.dig()
- end
- elseif i == keys.q then
- runin = false
- end
- end
- end
- function PN() -- PATCH NOTES
- clr()
- cp(1,1)
- print("===================")
- -- PATCH NOTES HERE --
- print("Disable a tunneling option")
- print("===================")
- print("")
- sleep(1)
- print("Press any key to continue")
- os.pullEvent()
- sleep(.3)
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment