Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Offset from the left
- -- Will be set at bottom of code
- offset = 0
- -- How far forward the turtle has gone
- distance = 0
- turtle.turnAround = function()
- turtle.turnRight()
- turtle.turnRight()
- end
- function forwardButWait(dist)
- -- Go forward the given distance, but wait for other things to get out of the way
- local goal = dist
- while goal > 0 do
- if turtle.forward() then
- goal = goal - 1
- end
- end
- end
- function forwardAndMine(dist)
- -- Go forward the given distance, mining things in the way
- local goal = dist
- while goal > 0 do
- turtle.dig()
- if turtle.forward() then
- goal = goal - 1
- end
- end
- end
- function pitstop()
- turtle.turnAround()
- forwardAndMine(distance)
- turtle.turnRight()
- forwardButWait(offset)
- turtle.turnLeft()
- for i=1,16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.turnRight()
- turtle.suck()
- turtle.refuel()
- turtle.turnAround()
- forwardButWait(offset)
- turtle.forward()
- offset = offset + 1
- distance = 0
- turtle.turnLeft()
- end
- function invfull()
- for i=1,16 do
- if turtle.getItemCount(i) == 0 then
- return false
- end
- end
- return true
- end
- function check()
- print("Fuel: " .. tostring(turtle.getFuelLevel()))
- if (turtle.getFuelLevel() <= distance + offset) or invfull() then
- print("Going for a pitstop!")
- pitstop()
- end
- end
- function mine()
- while true do
- check()
- turtle.dig()
- turtle.digUp()
- turtle.digDown()
- if turtle.forward() then
- distance = distance + 1
- end
- end
- end
- print("Mining begun.")
- turtle.refuel()
- while turtle.back() do end
- turtle.turnLeft()
- while turtle.forward() do end
- turtle.suck()
- turtle.refuel()
- print("Initial refuel done.")
- turtle.turnAround()
- while not turtle.detect() do
- offset = offset + 1
- turtle.forward()
- end
- turtle.dig()
- turtle.forward()
- offset = offset + 1
- turtle.turnLeft()
- print("Offset is " .. tostring(offset) .. ".")
- mine()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement