Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to mine a single row
- function mineRow(length)
- if length == 0 then
- return
- else
- -- Mine the block in front
- turtle.dig()
- -- Move forward
- if turtle.forward() then
- -- Recursively mine the next block
- mineRow(length - 1)
- end
- end
- end
- -- Function to mine the entire field
- function mineField(width, depth)
- if depth == 0 then
- return
- else
- -- Mine a single row
- mineRow(width)
- -- Turn around
- turtle.turnRight()
- turtle.turnRight()
- -- Go back to the start of the row
- for i=1, width do
- turtle.forward()
- end
- -- Position for the next row
- turtle.turnRight()
- if turtle.forward() then
- turtle.turnRight()
- -- Recursively mine the next layer
- mineField(width, depth - 1)
- else
- -- If we can't move forward, we've hit an obstacle or the edge of the field
- print("Unable to move to the next row.")
- return
- end
- end
- end
- -- Start mining the field
- mineField(6, 6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement