Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fuelLevel()
- if turtle.getFuelLevel() < 1000 then
- turtle.select(1)
- turtle.refuel(8)
- print("Refueled")
- else
- print("Enough Fuel")
- end
- end
- -- Function to move coal to slot 1 if below 40
- local function moveCoalToSlot1()
- local coalSlot = 1
- local currentCoalCount = turtle.getItemCount(coalSlot)
- local maxCoalCount = 40 -- Adjust this value as needed
- if currentCoalCount < maxCoalCount then
- for slot = 2, 16 do -- Start from slot 2 to avoid interfering with other items
- local item = turtle.getItemDetail(slot)
- if item and item.name == "minecraft:coal" then
- turtle.select(slot)
- turtle.transferTo(coalSlot)
- return true
- end
- end
- end
- return false
- end
- function mine()
- while turtle.detect() do
- turtle.dig()
- sleep(0.5)
- end
- turtle.forward()
- while turtle.detectUp() do
- turtle.digUp()
- sleep(0.5)
- end
- turtle.digDown()
- end
- function checkFull()
- if turtle.getItemCount(16) > 0 then
- -- Move to the designated chest drop-off point
- turtle.back()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- -- Place a chest if there's no chest below already
- turtle.select(3)
- if not turtle.detectDown() then
- turtle.placeDown()
- end
- -- Drop items from slots 4 to 16 into the chest
- for i = 4, 16 do
- turtle.select(i)
- turtle.dropDown()
- end
- -- Move back to the mining position
- turtle.select(2) -- Select torches again
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- end
- end
- print("Place fuel in slot 1, torches in slot 2, and chests in slot 3!")
- print("How wide will the tunnel be?")
- local x = tonumber(read())
- turtle.select(2)
- turtle.placeDown()
- while true do
- for i = 1, 9 do
- turtle.select(2)
- fuelLevel()
- moveCoalToSlot1() -- Check and move coal to slot 1 if needed
- checkFull()
- mine()
- turtle.turnLeft()
- for j = 1, ((x / 2) - 0.5) do
- mine()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for j = 1, (x - 1) do
- mine()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for j = 1, ((x / 2) - 0.5) do
- turtle.forward()
- end
- turtle.turnRight()
- end
- turtle.select(2)
- turtle.placeDown()
- end
Add Comment
Please, Sign In to add comment