Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("clear")
- local enderchest = false
- local torch = turtle.getItemCount(1)
- local chests = turtle.getItemCount(2)
- local dist = 0
- local retdist = 0
- local fuel = turtle.getFuelLevel()
- local t = 0
- function start()
- io.write "How deep do you want each branch? (Length) (1/99): "
- ll = io.read()
- if not tonumber(ll) then
- print ""
- print "Please enter a valid number"
- print ""
- start()
- else
- length = ll+1
- start_1()
- end
- if tonumber(length) < 1 then
- print ""
- print "Number must be positive"
- print ""
- start()
- end
- end
- function start_1()
- io.write "How many branches do you want? (Width) (1/99): "
- w = io.read()
- if not tonumber(w) then
- print ""
- print "Please enter a valid number"
- print ""
- start_1()
- else
- width = w+1
- start_2()
- end
- if tonumber(w) < 1 then
- print ""
- print "Number must be positive"
- print ""
- start_1()
- end
- end
- function start_2()
- io.write "Enderchest? (y/n): "
- e = io.read()
- if e == "y" then
- enderchest = true
- start_3()
- elseif e == "n" then
- enderchest = false
- start_3()
- else
- print ""
- print "Please enter y or n"
- print ""
- start_2()
- end
- end
- function start_3()
- print ("")
- print ("I will dig ".. w .. ", " .. ll .. " long tunnel(s)")
- if enderchest == true then
- print("Enderchest: Yes")
- else
- print("Enderchest: No")
- end
- io.write "Are you sure you want to procede? (y/n): "
- c = io.read()
- if c == "y" then
- --do stuff
- print "Off I go"
- elseif c == "n" then
- print "Be seeing you!"
- else
- print ""
- print "Please enter y or n"
- print ""
- start_3()
- end
- end
- function reFuel()
- turtle.select(3)
- turtle.refuel(1)
- local fuel = turtle.getFuelLevel()
- end
- function forward()
- if turtle.getFuelLevel() < 1 then
- reFuel()
- end
- if turtle.detect() then turtle.dig() end
- turtle.forward()
- dump()
- turtle.digUp()
- dump()
- dist = dist + 1
- print("dist:" .. dist)
- print("length:" .. length)
- end
- function dump()
- if turtle.getItemCount(16)>0 then
- turtle.digDown()
- turtle.select(2)
- turtle.placeDown()
- for slot = 4,15,1 do
- turtle.select(slot)
- turtle.dropDown()
- end
- if enderchest then
- turtle.select(2)
- turtle.digDown()
- else
- chests = chests - 1
- end
- end
- end
- function light()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(1)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- torch = torch - 1
- end
- function run()
- --[[print("torch:" .. torch)
- print("chests:" .. chests)
- print("fuel:" .. fuel)
- print("retdist:" .. retdist)]]--
- while (torch > 0) and (chests > 0) and (fuel > retdist) and (dist < tonumber(length)) do
- t = t + 1
- if t == 12 then
- light()
- t = 0
- end
- forward()
- --light()
- retdist = dist + 14
- local fuel = turtle.getFuelLevel()
- end
- --home()
- end
- start()
- if fuel == 0 then
- print("Better refuel")
- reFuel()
- end
- --run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement