Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MIN_FUEL_LEVEL = 300
- FUEL_SLOT = 1
- function checkFuel()
- turtle.select(FUEL_SLOT)
- if turtle.getFuelLevel()<MIN_FUEL_LEVEL then
- if turtle.refuel(1) then
- return true
- else
- return false--goHomeNOW()
- end
- end
- end
- function moveForward()
- checkFuel()
- if turtle.forward() then
- return true
- end
- return false
- end
- function moveBackward()
- checkFuel()
- if turtle.back() then
- return true
- end
- return false
- end
- function moveDownward()
- checkFuel()
- if turtle.down() then
- return true
- end
- return false
- end
- function moveUpward()
- checkFuel()
- if turtle.up() then
- return true
- end
- return false
- end
- function turnLeft()
- turtle.turnLeft()
- end
- function turnRight()
- turtle.turnRight()
- end
- function digMoveForward()
- repeat turtle.dig() until moveForward()
- turtle.digUp()
- turtle.digDown()
- end
- function digMoveDown()
- repeat turtle.digDown() until moveDownward()
- end
- function digMoveUp()
- repeat turtle.digUp() until moveUpward()
- end
- function tunnelForward(n)
- for i=1,n do
- digMoveForward()
- end
- end
- function main()
- print("DEPTH?")
- local depthS = read()
- local depth = tonumber(depthS)
- print("FRONT?")
- local frontS = read()
- local front = tonumber(frontS)
- print("LATERAL MOVEMENT (-L,+R)?")
- local lateralS = read()
- local lateral = tonumber(lateralS)
- print("TUNNEL LENGTH?")
- local lengthS = read()
- local length = tonumber(lengthS)
- for i=1,front do moveForward() end
- if lateral>0 then
- turnRight()
- for i=1,lateral do digMoveForward() end
- turnLeft()
- else
- turnLeft()
- for i=1,-lateral do digMoveForward() end
- turnRight()
- end
- for i=1,depth do digMoveDown() end
- tunnelForward(length)
- turnLeft()
- turnLeft()
- digMoveDown()
- digMoveDown()
- digMoveDown()
- tunnelForward(length)
- turnLeft()
- turnLeft()
- for i=1,depth+3 do digMoveUp() end
- if lateral>0 then
- turnRight()
- for i=1,lateral do moveBackward() end
- turnLeft()
- else
- turnLeft()
- for i=1,-lateral do moveBackward() end
- turnRight()
- end
- for i=1,front do moveBackward() end
- turnLeft()
- turnLeft()
- for i=2,16 do turtle.select(i)turtle.drop(64) end
- turnLeft()
- turnLeft()
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement