Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function checkFuel()
- repcount = 0
- fuelLevel = turtle.getFuelLevel()
- while fuelLevel <= 10 and repcount <= 5000 do
- for i = 1,16 do
- turtle.select(i)
- itemInfo = turtle.getItemDetail()
- if itemInfo ~= nil then
- if itemInfo.name == "minecraft:coal" then
- turtle.refuel()
- print("Refueled ", itemInfo["count"], " coal from slot", i)
- break
- end
- end
- end
- fuelLevel = turtle.getFuelLevel()
- repcount = repcount + 1
- end
- end
- function selectChest()
- hasChest = false
- for i = 1,16 do
- turtle.select(i)
- itemInSlot = turtle.getItemDetail()
- if itemInSlot ~= nil then
- if itemInSlot.name == "minecraft:chest" then
- hasChest = true
- turtle.digDown()
- turtle.placeDown()
- break
- end
- end
- end
- if hasChest == false then
- print("No chest in system, inventory is full, put a chest in the inventory")
- sleep(10)
- selectChest()
- end
- end
- function checkInventory()
- isFull = true
- itemSelect = 1
- turtle.select(itemSelect)
- for i = 1,16 do
- itemInSlot = turtle.getItemDetail(i)
- if itemInSlot == nill then
- isFull = false
- break
- end
- end
- if isFull == true then
- print("inventory is full, searching for chest to dump items")
- selectChest()
- dumpItems()
- end
- end
- function dumpItems()
- for i = 1,16 do
- turtle.select(i)
- itemInfo = turtle.getItemDetail()
- if itemInfo ~= nil then
- if itemInfo.name == "minecraft:chest" or itemInfo.name == "mincraft:coal" then
- print("This item in slot", i, "won't be dropped")
- else
- turtle.dropDown()
- end
- end
- end
- end
- function fwd()
- turtle.digUp()
- while turtle.forward() == false do
- turtle.dig()
- turtle.attack()
- checkFuel()
- checkInventory()
- end
- turtle.digUp()
- turtle.digDown()
- end
- function lfd()
- turtle.turnLeft()
- while turtle.forward() == false do
- turtle.dig()
- turtle.attack()
- checkFuel()
- checkInventory()
- end
- turtle.digUp()
- turtle.digDown()
- end
- function rfd()
- turtle.turnRight()
- while turtle.forward() == false do
- turtle.dig()
- turtle.attack()
- checkFuel()
- checkInventory()
- end
- turtle.digUp()
- turtle.digDown()
- end
- function initiate()
- print("How wide should the turtle go?")
- width = tonumber(read())
- print("How deep should the turtle go?")
- depth = tonumber(read())-1
- dig(width, depth)
- end
- function dig(width, depth)
- row = 1
- for i = 1,depth do
- fwd()
- end
- row = 2
- while row-1 <= width do
- for i = 2,depth do
- fwd()
- end
- print("Row",row, "is finshed")
- rfd()
- rfd()
- row = row + 1
- for i = 2,depth do
- fwd()
- end
- lfd()
- lfd()
- row = row+1
- end
- fwd()
- end
- function setCords()
- end
- initiate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement