Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local height = tonumber(args[1])
- local length = tonumber(args[2])
- local width = tonumber(args[3])
- print ("Height: " .. height .. "\n")
- print ("Length: " .. length .. "\n")
- print ("Width: " .. width .. "\n")
- local data = turtle.getItemDetail(1) -- fuel slot 1
- local fuelType = data.name
- function checkFuel ()
- if turtle.getFuelLevel() <= 0 then
- print ("no fuel\n")
- for i = 1, 16, 1 do
- if turtle.getItemDetail(i).name == fuelType then
- turtle.select(i)
- turtle.refuel()
- print ("refuel\n")
- return true
- end
- end
- print ("out of fuel\n")
- return false
- end
- return true
- end
- function dig ()
- while turtle.detect() do
- turtle.dig()
- end
- end
- function digUp ()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- function digDown ()
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- local len = 0
- local last = "down"
- local lastT = "left"
- checkFuel()
- dig()
- turtle.forward()
- len = len + 1
- while true do
- checkFuel()
- for i = 1, height - 1, 1 do
- if last == "down" then
- digUp()
- turtle.up()
- else
- digDown()
- turtle.down()
- end
- end
- if last == "down" then last = "up"
- else last = "down" end
- if len < length then
- dig()
- turtle.forward()
- len = len + 1
- elseif len >= length then
- len = 1
- if lastT == "left" then turtle.turnRight()
- else turtle.turnLeft() end
- dig()
- turtle.forward()
- if lastT == "left" then
- turtle.turnRight()
- lastT = "right"
- else
- turtle.turnLeft()
- lastT = "left"
- end
- end
- end
Add Comment
Please, Sign In to add comment