Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. local args = {...}
  2.  
  3. local function isEmpty(val)
  4. return val == nil or val == ""
  5. end
  6.  
  7. local function log(val)
  8. write(val .. "\n")
  9. end
  10.  
  11. local function validate(x, z, y)
  12. if x > 100 or z > 100 or y > 100 then
  13. log("Vc vai fazer merda mano. Não vou deixar mais do que 100.")
  14. return false
  15. end
  16.  
  17. return true
  18. end
  19.  
  20. local function refuel()
  21. for i=1,16 do
  22. turtle.select(i)
  23. if turtle.refuel() then
  24. log("Recarreguei, que delícia cara.")
  25. return true;
  26. end
  27. end
  28.  
  29. return false;
  30. end
  31.  
  32. local function checkFuel()
  33. if turtle.getFuelLevel() < 200 then
  34. log("Quase sem gasosa, tentando recarregar.")
  35. return refuel()
  36. end
  37. return true;
  38. end
  39.  
  40.  
  41.  
  42. local function start()
  43.  
  44. local x = tonumber(args[1])
  45. local z = tonumber(args[2])
  46. local y = tonumber(args[3])
  47.  
  48. if not validate(x, z, y) then
  49. return
  50. end
  51.  
  52. log("Parâmetros válidos.")
  53.  
  54. local turnRight = true
  55.  
  56. for curY = 1, y do
  57. for curX = 1, x do
  58. for curZ = 1, z do
  59. log("Posição x:" .. x .. " z:" .. z .. " y:" .. y)
  60. if not checkFuel() then
  61. term.setTextColor(colors.red);
  62. log("To sem gás viado.");
  63. term.setTextColor(colors.white);
  64. return;
  65. end
  66.  
  67. turtle.dig()
  68. turtle.forward()
  69. end
  70.  
  71. if curX ~= x then
  72. if turnRight then
  73. turtle.turnRight()
  74. turtle.forward()
  75. turtle.turnRight()
  76. else
  77. turtle.turnLeft()
  78. turtle.forward()
  79. turtle.turnLeft()
  80. end
  81. turnRight = not turnRight;
  82. end
  83. end
  84.  
  85. if curY ~= y then
  86. turtle.digDown()
  87. turtle.down()
  88. turtle.turnRight()
  89. turtle.turnRight()
  90. end
  91. end
  92. end
  93.  
  94. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement