Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --function declarations
- function fuelTurtle(needed)
- turtle.select(1)
- --Check if first slot has fuel
- if not turtle.refuel(0) then
- print("Waiting for Fuel in slot 1")
- --Wait for fuel
- while not turtle.refuel(0) do
- sleep(1)
- end
- end
- --refuel until good
- while needed >= turtle.getFuelLevel() do
- turtle.refuel(1)
- end
- end --End of Fuel Turtle
- function digFront()
- while turtle.detect() do
- turtle.dig()
- sleep(0.5)
- end
- end
- function digUp()
- while turtle.detectUp() do
- turtle.digUp()
- sleep(0.5)
- end
- end
- --main
- --Get input
- local distance, width, height = ...
- print("I shall commence mining")
- --Turn input to numbers
- distance = tonumber(distance)
- width = tonumber(width)
- height = tonumber(height)
- --If the turtle is facing right currently
- rightFacing = true
- --Repeats for distances down lane
- for x = distance, 1, -1 do
- --Check for fuel
- local fuelNeeded = width * height
- if fuelNeeded >= turtle.getFuelLevel() then
- fuelTurtle(fuelNeeded + width)
- end
- local heightLeft = height - 1
- --Commit mining
- --Dig block in front
- digFront()
- turtle.forward()
- if rightFacing then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- heightLeft = height
- --Goes along height
- while heightLeft > 0 do
- --Goes along width
- for move = width - 1, 1, -1 do
- --Mines block in front, and top if appropiate and move forward
- if heightLeft > 1 then
- digUp()
- end
- digFront()
- turtle.forward()
- end
- if heightLeft > 1 then
- digUp()
- end
- --Set to mined height
- heightLeft = heightLeft - 2
- --Checks if there is height left, then go up there
- if heightLeft >= 1 then
- turtle.up()
- digUp()
- turtle.up()
- end
- turtle.turnRight()
- turtle.turnRight()
- rightFacing = not rightFacing
- end
- --Face Wall
- if rightFacing then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- for h = height - 1, 1, -1 do
- turtle.down()
- end
- end
- print("Done!")
Add Comment
Please, Sign In to add comment