Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ACCEPTABLE_FUEL = {"minecraft:coal"}
- FUEL_COUNT = -1
- FUEL_INDEX = -1
- -- Utilities
- function arrHasValue(arr, val)
- for index, value in ipairs(arr) do
- if value == val then
- return true
- end
- end
- return false
- end
- -- Fuel
- function hasFuel()
- return FUEL_COUNT > 0
- end
- function shouldRefuel()
- return turtle.getFuelLevel() <= 0
- end
- function refuel()
- if shouldRefuel() == true then
- if hasFuel() ~= true then
- return false
- end
- turtle.select(1)
- turtle.refuel(1)
- FUEL_COUNT = FUEL_COUNT - 1
- end
- return true
- end
- -- Inventory
- function getSlotData(index)
- turtle.select(index)
- local slotData = turtle.getItemDetail()
- return slotData
- end
- function main()
- -- Setup
- for i=1, 16 do
- local curr_slot_data = getSlotData(i)
- if curr_slot_data ~= nil then
- if FUEL_INDEX == -1 then
- if arrHasValue(ACCEPTABLE_FUEL, curr_slot_data["name"]) then
- FUEL_INDEX = i
- FUEL_COUNT = curr_slot_data["count"]
- break
- end
- end
- end
- end
- if FUEL_INDEX == -1 then
- print("No fuel!")
- return
- end
- print("Fuel Index: " .. FUEL_INDEX)
- while true do
- if refuel() == false then
- print("Ran out of fuel!")
- return
- end
- local has_block, data = turtle.inspect()
- if has_block then
- if data["name"] == "minecraft:cobblestone" then
- break
- end
- end
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement