Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- local item = "coal"
- if #tArgs > 0 then
- item = tArgs[1]
- end
- local slotWithEnderChest = 16
- currentSlot = turtle.getSelectedSlot()
- print("Refuelling")
- if turtle.detectUp() then
- turtle.digUp()
- end
- -- Place the ender chest
- turtle.select(slotWithEnderChest)
- turtle.placeUp()
- turtle.select(currentSlot)
- chest = peripheral.wrap("top")
- inventorySize = chest.getInventorySize()
- for i=1,inventorySize do
- currentItem = chest.getStackInSlot(i)
- if currentItem == nil then
- break
- end
- if currentItem["name"] == item then
- -- Find the first inventory slot in the turtle
- freeSlot = -1
- for j=1,16 do
- print("Checking slot "..j..":"..turtle.getItemCount(j))
- if turtle.getItemCount(j) == 0 then
- freeSlot = j
- print("Found free slot "..j)
- break
- end
- end
- chest.pushItemIntoSlot("down", i, 64, freeSlot)
- turtle.select(i)
- turtle.refuel()
- end
- end
- turtle.select(slotWithEnderChest)
- turtle.digUp()
- turtle.select(currentSlot)
- print(turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment