Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function checkForBedrockFront()
- local success, data = turtle.inspect()
- if data.name == 'minecraft:bedrock' then
- print('Bedrock reached, program stopped')
- while true do
- end
- end
- end
- function checkForBedrockDown()
- local success, data = turtle.inspectDown()
- if data.name == 'minecraft:bedrock' then
- print('Bedrock reached, program stopped')
- while true do
- end
- end
- end
- function turnAroundRight()
- turtle.turnRight()
- repeat
- checkForBedrockFront()
- turtle.dig()
- checkInventoryFull()
- until(turtle.forward())
- turtle.digUp()
- checkInventoryFull()
- turtle.digDown()
- checkInventoryFull()
- turtle.turnRight()
- checkFuel()
- end
- function turnAroundLeft()
- turtle.turnLeft()
- repeat
- checkForBedrockFront()
- turtle.dig()
- checkInventoryFull()
- until(turtle.forward())
- turtle.digUp()
- checkInventoryFull()
- turtle.digDown()
- checkInventoryFull()
- turtle.turnLeft()
- checkFuel()
- end
- function checkInventoryFull()
- -- search for empty slot
- for slot = 3, 16, 1 do
- if turtle.getItemCount(slot) == 0 then
- return
- end
- end
- -- empty inventory into ender chest
- turtle.select(1)
- turtle.placeUp()
- for slot = 3, 16, 1 do
- turtle.select(slot)
- turtle.refuel()
- while not turtle.dropUp() and turtle.getItemCount(slot) ~= 0 do -- wait if chest is full
- print('Waiting for ender chest to become empty...')
- end
- term.clear()
- end
- turtle.select(1)
- turtle.digUp()
- end
- function checkFuel()
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel < 5 then
- -- check for fuel in inventory
- for slot = 3, 16, 1 do
- turtle.select(slot)
- if turtle.refuel() then
- return
- end
- end
- -- get fuel from ender chest
- turtle.select(2)
- turtle.placeUp()
- turtle.select(3)
- while not turtle.suckUp() do -- wait if chest is empty
- print('Waiting for fuel to become available...')
- end
- term.clear()
- turtle.select(2)
- turtle.digUp()
- -- get gathered fuel from inventory
- for slot = 3, 16, 1 do
- turtle.select(slot)
- if turtle.refuel() then
- return
- end
- end
- end
- end
- function digAndMoveForward()
- repeat
- checkForBedrockFront()
- turtle.dig()
- checkInventoryFull()
- until(turtle.forward())
- turtle.digUp()
- checkInventoryFull()
- turtle.digDown()
- checkInventoryFull()
- checkFuel()
- end
- function digAndMoveDown()
- repeat
- checkForBedrockDown()
- turtle.digDown()
- checkInventoryFull()
- until(turtle.down())
- turtle.digDown()
- checkInventoryFull()
- checkFuel()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement