Advertisement
EnderReaper64

Computercraft Geoscanner Turtle (Does not currently work)

Sep 30th, 2022
1,327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.11 KB | Software | 0 0
  1. local scanner = peripheral.find("geoscanner")
  2. local fuel = turtle.getFuelLevel()
  3. print("What block to mine?")
  4. local search = io.read()
  5. local direction = 0
  6. local offset = {0, 0, 0}
  7.  
  8. function turnRight()
  9.     turtle.turnRight()
  10.     direction += 1
  11.     if direction > 3 then
  12.         direction = 0
  13.     end
  14. end
  15. function turnLeft()
  16.     turtle.turnLeft()
  17.     direction += 1
  18.     if direction < 0 then
  19.         direction = 3
  20.     end
  21. end
  22.  
  23. function moveX(distance)
  24.     if distance > 0 then
  25.         if direction == 0 then
  26.             turnRight()
  27.         elseif direction == 3 then
  28.             turnRight()
  29.             turnRight()
  30.         if direction == 2 then
  31.             turnLeft()
  32.         end
  33.     else
  34.         if direction == 0 then
  35.             turnLeft()
  36.         elseif direction == 2 then
  37.             turnRight()
  38.         if direction == 1 then
  39.             turnRight()
  40.             turnRight()
  41.         end
  42.     end
  43.     for a = 1, distance do
  44.         turtle.dig()
  45.         turtle.forward()
  46.         offset = {offset[x]+(math.abs(distance)/distance), offset[y], offset[z]}
  47.     end
  48. end
  49.  
  50. function moveZ(distance)
  51.     if distance > 0 then
  52.         if direction == 1 then
  53.             turnRight()
  54.         elseif direction == 3 then
  55.             turnLeft()
  56.         if direction == 0 then
  57.             turnRight()
  58.             turnRight()
  59.         end
  60.     else
  61.         if direction == 2 then
  62.             turnRight()
  63.         elseif direction == 0 then
  64.             turnLeft()
  65.         if direction == 1 then
  66.             turnRight()
  67.             turnRight()
  68.         end
  69.     end
  70.     for a = 1, distance do
  71.         turtle.dig()
  72.         turtle.forward()
  73.         offset = {offset[x], offset[y], offset[z]+(math.abs(distance)/distance)}
  74.     end
  75. end
  76.  
  77. function moveY(distance)
  78.     if distance > 0 then
  79.         turtle.digUp()
  80.         turtle.up()
  81.         {offset[x], offset[y]+1, offset[z]}
  82.     else
  83.         turtle.digDown()
  84.         turtle.down()
  85.         {offset[x], offset[y]-1, offset[z]}
  86.     end
  87. end
  88.  
  89. function Move(vector)
  90.     moveX(vector[1])
  91.     moveY(vector[2])
  92.     moveZ(vector[3])
  93. end
  94.  
  95. Move(1, 1, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement