Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function EatFuel()
- for i = 1,16,1 do
- local data = turtle.getItemDetail(i)
- if data then
- if data.name == "minecraft:coal" then
- turtle.select(i)
- turtle.refuel(1)
- return true
- end
- end
- end
- return false
- end
- function CheckFuelAndRefuel()
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel == 0 then
- if EatFuel() == false then
- return false
- end
- end
- end
- function CanGetHome(dist)
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel-1 <= dist then
- local res = EatFuel()
- return res
- end
- return true
- end
- function ManageInventory()
- AllowedItemsTable = {
- ["minecraft:diamond"] = true,
- ["minecraft:emerald"] = true,
- ["minecraft:redstone"] = true,
- ["minecraft:lapiz"] = true,
- ["minecraft:coal"] = true,
- ["galacticraftcore:basic_item"] = true,
- ["galacticraftcore:basic_block_core"] = true,
- ["minecraft:dye"] = true
- }
- for i = 1,16,1 do
- local data = turtle.getItemDetail(i)
- if data then
- if AllowedItemsTable[data.name] == nil then
- turtle.select(i)
- turtle.drop()
- end
- end
- end
- end
- function Quarry()
- local distance = 0
- local digsuccess = true
- local belowempty = false
- local success = true
- repeat
- digsuccess = turtle.digDown()
- belowempty = not turtle.detectDown()
- success = digsuccess or belowempty
- if success then
- turtle.suckDown()
- ManageInventory()
- if CanGetHome(distance) then
- turtle.down()
- distance = distance + 1
- else
- print("Cant get home with distance " .. distance .. " and fuel " .. turtle.getFuelLevel())
- break
- end
- else
- print("Cant dig down anymore. So I'm going back up")
- end
- until(success == false)
- print("Going home")
- for i = 1,distance,1 do
- turtle.up()
- end
- end
- Quarry()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement