Advertisement
montana_1

consumeFuel

Oct 25th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. function consumeFuel(maxFuel)
  2.     local refuel = false
  3.     for i = 1, 16 do -- loop through the slots
  4.         turtle.select(i) -- change to the slot
  5.         local x = turtle.getItemDetail(i)
  6.         if(x ~= nil) then
  7.             local istr = string.sub(x.name,string.find(x.name,":",0)+1)
  8.             print(istr,"    t")
  9.             if(istr == "planks" or istr == "stick" or istr == "log") then
  10.                 turtle.refuel()
  11.                 refuel = true
  12.             end
  13.             if(turtle.getFuelLevel() < maxFuel and istr == "coal") then
  14.                 turtle.refuel(1)
  15.                 refuel = true
  16.             end
  17.         end
  18.     end
  19.     turtle.select(1)
  20.     print(turtle.getFuelLevel())
  21.     return refuel
  22. end
  23.  
  24.  
  25. print(consumeFuel(400))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement