Advertisement
theluksabm

Untitled

Apr 6th, 2020
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 KB | None | 0 0
  1.  
  2. local prefix = "[Carlos 0.1a] "
  3.  
  4.  
  5. -- Funcao printf
  6. local function printf(...) print(string.format(...)) end
  7.  
  8. -- Funcao combustivel
  9. local function combustivel()
  10.     local restante = turtle.getFuelLevel() -- Combustivel restante
  11.  
  12.     if restante == 0 then
  13.         printf("%s Sem combustivel restante, tentando reabastecer.", prefix)
  14.         for i = 1, 16 do
  15.             turtle.select(i)
  16.             if turtle.refuel(0) then
  17.                 local halfStack = math.ceil(turtle.getItemCount(i)/2)
  18.                 turtle.refuel(halfStack)
  19.             end
  20.         end
  21.     else:
  22.         printf("%s Combustivel restante: %s", prefix, restante)
  23.     end
  24. end
  25.  
  26.  
  27. combustivel()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement