Advertisement
theluksabm

Untitled

Apr 7th, 2020
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 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("%sSem 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("%sCombustivel 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. printf("Teste " .. a, b)
  43.  
  44. while possivel do
  45.  
  46. for i=1,a do
  47. turtle.dig()
  48. turtle.forward()
  49. i = i + 1
  50. possivel = combustivel()
  51. end
  52. break
  53.  
  54. end
  55. end
  56.  
  57.  
  58. -- Codigo
  59. write(prefix .. "Digite a area para ser minerada: ")
  60. local a,b = read(a,b)
  61.  
  62. minerar(a,b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement