Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local enderchest = false
- local torch = turtle.getItemCount(1)
- local chests = turtle.getItemCount(2)
- local dist = 0
- function dump()
- if turtle.getItemCount(16)>0 then
- turtle.digDown()
- turtle.select(2)
- turtle.placeDown()
- for slot = 3,16,1 do
- turtle.select(slot)
- turtle.dropDown()
- end
- if enderchest then
- turtle.select(2)
- turtle.digDown()
- end
- end
- end
- function digforw()
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- dump()
- turtle.digUp()
- dump()
- dist = dist + 1
- end
- function home()
- turtle.turnLeft()
- turtle.turnLeft()
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.up()
- for i=1,dist,1 do
- turtle.forward()
- end
- turtle.down()
- if torch==0 then
- print("Ran out of torches.")
- elseif chests==0 then
- print("Ran out of chests.")
- else
- print("Ran out of fuel.")
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function light()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(1)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- torch = torch - 1
- end
- local retdist = 0
- local fuel = turtle.getFuelLevel()
- function run()
- while (torch>0) and (chests>0) and (fuel>retdist) do
- for i=1,12,1 do
- digforw()
- end
- light()
- retdist = dist + 14
- fuel = turtle.getFuelLevel()
- end
- home()
- end
- run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement