Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 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 > 62 then
  77. if turtle.down() then
  78. y = y - 1
  79. end
  80. if turtle.detectDown() then
  81. if y > 63 then
  82. turtle.digDown()
  83. end
  84. end
  85. end
  86. cache = 0
  87. end
  88.  
  89. end
  90.  
  91. function moveF()
  92. if turtle.forward() then
  93. if facing%4 == 0 then
  94. z = z + 1
  95. end
  96. if facing%4 == 3 then
  97. x = x + 1
  98. end
  99. if facing%4 == 2 then
  100. z = z - 1
  101. end
  102. if facing%4 == 1 then
  103. x = x - 1
  104. end
  105. --turtle.forward()
  106. end
  107. end
  108.  
  109. while true do
  110. term.clear()
  111. print("\n")
  112. print(x)
  113. print("\n")
  114. print(y)
  115. print("\n")
  116. print(z)
  117. while cachemov == 2 do
  118. print("\nInserte coordena X :")
  119. x = tonumber(read())
  120. print("\nInserte coordena Y :")
  121. y = tonumber(read())
  122. print("\nInserte coordena Z :")
  123. z = tonumber(read())
  124. print("\nInserte coordena +X:")
  125. x2= tonumber(read())
  126. print("\nInserte coordena +Y:")
  127. y2= tonumber(read())
  128. print("\nInserte coordena +Z:")
  129. z2= tonumber(read())
  130. print("\nInserte hacia donde se dirije la cara (0N 3E 2S 1O):")
  131. facing = tonumber(read())
  132. sleep(0)
  133. x1 = x
  134. y1 = y
  135. z1 = z
  136. cachemov = 0
  137. end
  138. ref()
  139. explore()
  140. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement