Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1.  
  2. local cache = 0
  3. local cachemov = 2
  4. local x,y,z = 0,0,0
  5. local x1,y1,z1 = 0,0,0
  6. local x2,y2,z2 = 0,0,0
  7. local facing = 0
  8.  
  9. function ref()
  10. if turtle.getFuelLevel() < 2 then
  11. turtle.refuel()
  12. end
  13. end
  14.  
  15. function explore()
  16. while (x < x1) or (x > x2) do
  17. print("limiteX")
  18. if (x < x1+2) and (x < x2+2) then
  19. if facing%4 == 3 then
  20. moveF()
  21. else
  22. turtle.turnLeft()
  23. facing = facing + 1
  24. end
  25. end
  26. if (x > x1-2) and (x > x2-2) then
  27. if facing%4 == 1 then
  28. moveF()
  29. else
  30. turtle.turnLeft()
  31. facing = facing + 1
  32. end
  33. end
  34. end
  35. while (z < z1) or (z > z2) do
  36. print("limiteZ")
  37. if (z < z1+2) and (z < z2+2) then
  38. if facing%4 == 0 then
  39. moveF()
  40. else
  41. turtle.turnLeft()
  42. facing = facing + 1
  43. end
  44. end
  45. if (z > z1-2) and (z > z2-2) then
  46. if facing%4 == 2 then
  47. moveF()
  48. else
  49. turtle.turnLeft()
  50. facing = facing + 1
  51. end
  52. end
  53. end
  54. if turtle.detectUp() then
  55. if y < y2 then
  56. cachemov = 1
  57. turtle.digUp()
  58. end
  59. end
  60. if cachemov == 1 then
  61. turtle.up()
  62. y = y + 1
  63. cache = 0
  64. cachemov = 0
  65. end
  66. if turtle.dig() then
  67. cache = 0
  68. turtle.dig()
  69. moveF()
  70. else
  71. turtle.turnLeft()
  72. facing = facing + 1
  73. cache = cache + 1
  74. end
  75. if cache >= 4 then
  76. if y > 64 then
  77. if turtle.detectDown() then
  78. if turtle.digDown() then
  79. y = y - 1
  80. end
  81. else
  82. if turtle.down() then
  83. y = y - 1
  84. end
  85. end
  86. end
  87. cache = 0
  88. end
  89.  
  90. end
  91.  
  92. function moveF()
  93. if turtle.forward() then
  94. if facing%4 == 0 then
  95. z = z + 1
  96. end
  97. if facing%4 == 3 then
  98. x = x + 1
  99. end
  100. if facing%4 == 2 then
  101. z = z - 1
  102. end
  103. if facing%4 == 1 then
  104. x = x - 1
  105. end
  106. --turtle.forward()
  107. end
  108. end
  109.  
  110. while true do
  111. term.clear()
  112. print("\n")
  113. print(x)
  114. print("\n")
  115. print(y)
  116. print("\n")
  117. print(z)
  118. while cachemov == 2 do
  119. print("\nInserte coordena X :")
  120. x = tonumber(read())
  121. print("\nInserte coordena Y :")
  122. y = tonumber(read())
  123. print("\nInserte coordena Z :")
  124. z = tonumber(read())
  125. print("\nInserte coordena +X:")
  126. x2= tonumber(read())
  127. print("\nInserte coordena +Y:")
  128. y2= tonumber(read())
  129. print("\nInserte coordena +Z:")
  130. z2= tonumber(read())
  131. print("\nInserte hacia donde se dirije la cara (0N 3E 2S 1O):")
  132. facing = tonumber(read())
  133. sleep(0)
  134. x1 = x
  135. y1 = y
  136. z1 = z
  137. cachemov = 0
  138. end
  139. ref()
  140. explore()
  141. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement