Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TRAVEL_DIST = 64
- 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 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,
- ["minecraft:iron_ore"] = 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
- turtle.select(1)
- end
- function CheckFuelAndRefuel()
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel == 0 then
- if EatFuel() == false then
- return false
- end
- end
- end
- function Mine()
- local distance = 0
- for i = 1,TRAVEL_DIST,1 do
- local didDig = false
- if CanGetHome(distance) then
- local success, data = turtle.inspect()
- if success then
- if data.name == "minecraft:gravel" or data.name == "minecraft:sand" then
- while(success) do
- didDig = turtle.dig() or didDig
- success, data = turtle.inspect()
- end
- else
- didDig = turtle.dig() or didDig
- end
- end
- turtle.forward()
- distance = distance + 1
- didDig = turtle.digUp() or didDig
- if didDig then
- turtle.suck()
- ManageInventory()
- end
- else
- print("I can't get home if I continue")
- break
- end
- end
- print("Going home")
- for i = 1,distance,1 do
- turtle.back()
- end
- end
- function Iterate()
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel-3 <= 0 then
- local res = EatFuel()
- if res == false then
- print("Not enough fuel to mine another tunnel")
- return false
- end
- end
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.turnRight()
- end
- function main()
- while true do
- Mine()
- local success = Iterate()
- if success == false then
- return
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement