Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local width = 10 -- Number of horizontal rows
- local depth = 10 -- Length of each row
- local height = 100 -- Number of vertical layers
- local currentLayer = 0 -- Current layer the turtle is on
- function checkFuel()
- if turtle.getFuelLevel() < 10 then
- print("Refueling...")
- turtle.select(1) -- Assuming fuel is in the first slot
- turtle.refuel(1) -- Refuels using 1 item
- end
- end
- function depositItems()
- print("Depositing items...")
- -- If the turtle is not on the first layer, move up to the first layer
- for i = 1, currentLayer do
- turtle.up()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 2, 16 do -- Slot 1 is for fuel, so we start from 2
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- turtle.turnRight()
- turtle.turnRight()
- -- Move back down to the original layer
- for i = 1, currentLayer do
- turtle.down()
- end
- end
- function returnToLayerStart()
- if width % 2 == 0 then -- If we finished on an even row
- turtle.forward()
- turtle.turnRight()
- for i = 1, depth - 1 do
- turtle.forward()
- end
- turtle.turnRight()
- else -- We finished on an odd row
- turtle.turnLeft()
- for i = 1, depth - 1 do
- turtle.forward()
- end
- turtle.turnLeft()
- end
- end
- function digLayer()
- for w = 1, width do
- for d = 1, depth do
- checkFuel()
- while turtle.detect() do
- turtle.dig()
- end
- if d < depth or w < width then -- Avoid forward movement at the end of each width and the very last block of the layer
- turtle.forward()
- end
- if turtle.getItemCount(16) > 0 then -- If the last slot in inventory is filled
- depositItems()
- end
- end
- if w < width then -- Not the last row
- if w % 2 == 0 then -- For even rows
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- else -- For odd rows
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- end
- end
- end
- returnToLayerStart()
- -- Deposit items and check fuel once the turtle is back at the starting position
- depositItems()
- checkFuel()
- -- Increase current layer count
- currentLayer = currentLayer + 1
- -- At the end of the layer, dig the block below and move down
- if turtle.detectDown() then
- turtle.digDown()
- end
- turtle.down()
- end
- function startStripMine()
- for h = 1, height do
- print("Mining layer number " .. h)
- digLayer()
- end
- print("Finished strip mining!")
- end
- startStripMine()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement