Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function select_fuel()
- local slot = 1
- local data
- while slot <= 16 do
- data = turtle.getItemDetail(slot)
- if data and (data.name == "minecraft:lava_bucket" or data.name == "minecraft:coal" or data.name == "minecraft:planks" or data.name == "minecraft:log") then
- turtle.select(slot)
- return true
- end
- slot = slot + 1
- end
- return false
- end
- function is_inventory_full()
- local slot = 1
- local data
- while slot <= 16 do
- data = turtle.getItemDetail(slot)
- if not data then
- return false
- end
- slot = slot + 1
- end
- return true
- end
- function check_fuel()
- if turtle.getFuelLevel() < 10 then
- while not select_fuel() do
- print("Waiting fuel. Retrying refuel in 10 seconds.")
- sleep(10)
- end
- turtle.refuel()
- end
- end
- function avance()
- local grav = 0
- local success, data
- while not turtle.forward() do
- success, data = turtle.inspect()
- check_fuel()
- if success then
- turtle.dig()
- if data.name == "minecraft:gravel" then
- grav = grav + 1
- end
- end
- end
- return grav
- end
- function recule()
- while not turtle.back() do
- check_fuel()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.dig()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- function dig_collumn(grav)
- local z, ntp = 0, 0
- while turtle.detectUp() or grav > 0 or ntp > 0 do
- check_fuel()
- while not turtle.up() do
- turtle.digUp()
- turtle.suckUp()
- ntp = ntp + 1
- end
- turtle.suckUp()
- z = z + 1
- if ntp > 0 then ntp = ntp - 1 end
- if grav > 0 then grav = grav - 1 end
- end
- turtle.suck()
- turtle.suckUp()
- while z > 0 do
- if not turtle.down() then
- check_fuel()
- turtle.digDown()
- end
- z = z - 1
- end
- end
- function stone_down()
- local success, data = turtle.inspectDown()
- if success and data.name ~= "minecraft:dirt" and data.name ~= "minecraft:grass" then
- return true
- elseif not turtle.detectDown() then
- return true
- end
- return false
- end
- function select_dirt()
- local i = 1
- local data
- while i < 16 do
- data = turtle.getItemDetail(i)
- if data and data.name == "minecraft:dirt" then
- turtle.select(i)
- return true
- end
- i = i + 1
- end
- return false
- end
- function replace_bloc_by_dirt()
- if select_dirt() then
- turtle.digDown()
- turtle.placeDown()
- end
- end
- function drop_all_bottom()
- local slot = 1
- local data
- while slot <= 16 do
- data = turtle.getItemDetail(slot)
- if data and data.name ~= "minecraft:coal" then
- turtle.select(slot)
- if not turtle.dropDown() then
- break
- end
- end
- slot = slot + 1
- end
- end
- function get_chest_presence()
- local success, data = turlte.inspectDown()
- if success and data.name == "minecraft:chest" then
- drop_all_bottom()
- end
- end
- function multavance(x)
- while x > 0 do
- avance()
- x = x - 1
- end
- end
- function goto_base_and_drop(x, y)
- turtle.turnLeft()
- turtle.turnLeft()
- multavance(x)
- turtle.turnRight()
- multavance(y)
- turtle.turnRight()
- drop_all_bottom()
- turtle.turnRight()
- multavance(y)
- turtle.turnLeft()
- multavance(x)
- end
- function select_next_item(slot, item)
- local data
- while slot <= 16 do
- data = turtle.getItemDetail(slot)
- if data and data.name == item then
- turtle.select(slot)
- return true
- end
- slot = slot + 1
- end
- return false
- end
- function repack_item(item)
- local slot = 1
- local data
- while slot < 16 do
- data = turtle.getItemDetail(slot)
- if not data or (data.name == item and data.count < 64) then
- if select_next_item(slot + 1, item) then
- turtle.transferTo(slot)
- data = turtle.getItemDetail(slot)
- else
- return true
- end
- end
- if data and ((data.name == item and data.count == 64) or data.name ~= item) then
- slot = slot + 1
- end
- end
- return true
- end
- function clean_inventory(x, y)
- local slot = 1
- local data
- while slot <= 16 do
- data = turtle.getItemDetail(slot)
- if data and (data.name == "minecraft:diamond" or data.name == "minecraft:emerald" or data.name == "minecraft:redstone" or data.name == "minecraft:iron_ore" or data.name == "minecraft:gold_ore" or data.name == "minecraft:coal" or (data.name == "minecraft:dye" and data.damage == 4) or data.name == "minecraft:lava_bucket" or data.name == "minecraft:coal" or data.name == "minecraft:planks" or data.name == "minecraft:log" or data.name == "minecraft:sand") then
- repack_item(data.name)
- elseif data then
- turtle.select(slot)
- turtle.drop()
- end
- slot = slot + 1
- end
- if is_inventory_full() then
- goto_base_and_drop(x, y)
- end
- end
- local x, y = 0, 0
- print("How metters dig in front off ?")
- local xmax = tonumber(read())
- print("How metters dig at right ?")
- local ymax = tonumber(read())
- local grav = 0
- while y < ymax or x < xmax do
- check_fuel()
- if turtle.detectUp() then dig_collumn(0) end
- grav = 0
- if x == xmax then
- while x > 0 do
- recule()
- x = x - 1
- end
- turtle.turnRight()
- avance()
- turtle.turnLeft()
- y = y + 1
- else
- grav = avance()
- x = x + 1
- if turtle.detectUp() or grav > 0 then dig_collumn(grav) end
- if stone_down() then replace_bloc_by_dirt() end
- if is_inventory_full() then clean_inventory(x, y) end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement