Advertisement
Alexr360

Turtle Fuel

Feb 24th, 2024
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.50 KB | None | 0 0
  1. -- Function to refuel the turtle
  2. function refuel()
  3.     -- Loop over each slot in the turtle's inventory
  4.     for i = 1, 16 do
  5.         -- Select the slot
  6.         turtle.select(i)
  7.  
  8.         -- If the selected slot contains an item, try to refuel with it
  9.         if turtle.getItemCount(i) > 0 then
  10.             turtle.refuel(1)
  11.         end
  12.     end
  13.  
  14.     -- Print out the turtle's current fuel level
  15.     print("Current fuel level: " .. turtle.getFuelLevel())
  16. end
  17.  
  18. -- Call the refuel function
  19. refuel()
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement