Advertisement
theluksabm

Untitled

Apr 7th, 2020
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 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.  
  9. -- Funcao combustivel
  10. local function combustivel()
  11.     local restante = turtle.getFuelLevel() -- Combustivel restante
  12.     local suficiente = false
  13.  
  14.     while true do
  15.         if restante == 0 then
  16.             suficiente = false
  17.             printf("%s Sem combustivel restante, tentando reabastecer.", prefix)
  18.             for i = 1, 16 do
  19.                 turtle.select(i)
  20.                 if turtle.refuel(0) then
  21.                     local halfStack = math.ceil(turtle.getItemCount(i)/2)
  22.                     turtle.refuel(halfStack)
  23.                     restante = turtle.getFuelLevel()
  24.                     suficiente = true
  25.                     break
  26.                 end
  27.             end
  28.         else
  29.             printf("%s Combustivel restante: %s", prefix, restante)
  30.             suficiente = true
  31.             break
  32.         end
  33.     end
  34.     return suficiente
  35.  
  36. end
  37.  
  38.  
  39. -- Funcao minerar
  40. local function minerar(a, b)
  41.     local possivel = combustivel()
  42.  
  43.     while possivel do
  44.         turtle.dig()
  45.         turtle.forward()
  46.         possivel = combustivel()
  47.     end
  48.  
  49. end
  50.  
  51. minerar()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement