Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function refuel()
- -- Loop over each slot in the turtle's inventory
- for i = 1, 16 do
- -- Select the slot
- turtle.select(i)
- -- Get the count of items in the slot
- local itemCount = turtle.getItemCount(i)
- -- While there are items in the slot and refueling hasn't reached 64 times
- local refuelCount = 0
- while itemCount > 0 and refuelCount < 64 do
- if turtle.refuel(1) then
- refuelCount = refuelCount + 1
- itemCount = turtle.getItemCount(i) -- Update item count after refueling
- else
- break -- Exit if unable to refuel
- end
- end
- end
- -- Print out the turtle's current fuel level
- print("Current fuel level: " .. turtle.getFuelLevel())
- end
- -- Call the refuel function
- refuel()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement