Advertisement
CaptainSpaceCat

OreTest

Apr 12th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.94 KB | None | 0 0
  1. function breakorecheck()
  2.     f1, f2 = turtle.inspect()
  3.     u1, u2 = turtle.inspectUp()
  4.     d1, d2 = turtle.inspectDown()
  5.    
  6. --other blocks to do       
  7.     if u2.name == "minecraft:iron_ore" then
  8.         up = 1
  9.     end
  10.     if d2.name == "minecraft:iron_ore" then
  11.         down = 1
  12.     end
  13.  
  14. --other layers to do
  15.     if f2.name == "minecraft:iron_ore" then
  16.         forward = 1
  17.     end
  18.  
  19. --other columns to do
  20.     turtle.turnLeft()
  21.     f1, f2 = turtle.inspect()
  22.     if f2.name == "minecraft:iron_ore" then
  23.         left = 1
  24.     end
  25.     shell.run("go right 2")
  26.     f1, f2 = turtle.inspect()
  27.     if f2.name == "minecraft:iron_ore" then
  28.         right = 1
  29.     end
  30.     turtle.turnLeft()
  31. end
  32.  
  33. function resetvarsore()
  34.     up = 0
  35.     down = 0
  36.     forward = 0
  37.     left = 0
  38.     right = 0
  39. end
  40.  
  41. function oreupdown()
  42.     breakorecheck()
  43.     while up == 1 do
  44.         turtle.digUp()
  45.         turtle.up()
  46.         ud = ud + 1
  47.         breakorecheck()
  48.         u1, u2 = turtle.inspectUp()
  49.         if u2.name ~= "minecraft:iron_ore" then
  50.             up = 0
  51.         end
  52.     end
  53.     while ud ~= 0 do
  54.         turtle.digDown()
  55.         turtle.down()
  56.         ud = ud - 1
  57.     end
  58.     breakorecheck()
  59.     while down == 1 do
  60.         turtle.digDown()
  61.         turtle.down()
  62.         ud = ud - 1
  63.         breakorecheck()
  64.         d1, d2 = turtle.inspectDown()
  65.         if d2.name ~= "minecraft:iron_ore" then
  66.             down = 0
  67.         end
  68.     end
  69.     while ud ~= 0 do
  70.         turtle.digUp()
  71.         turtle.up()
  72.         ud = ud + 1
  73.     end
  74. end
  75.  
  76. --left is positive lr
  77. function oreleft()
  78.     turtle.turnLeft()
  79.     f1, f2 = turtle.inspect()
  80.     while f2.name ~= "minecraft:iron_ore" and u1 == false do
  81.         turtle.up()
  82.         u1, u2 = turtle.inspectUp()
  83.         f1, f2 = turtle.inspect()
  84.         ud = ud + 1
  85.     end
  86.     while f2.name ~= "minecraft:iron_ore" and d1 == false do
  87.         turtle.down()
  88.         d1, d2 = turtle.inspectDown()
  89.         f1, f2 = turtle.inspect()
  90.         ud = ud - 1
  91.     end
  92.     turtle.dig()
  93.     turtle.forward()
  94.     left = 0
  95.     turtle.turnRight()
  96.     oreupdown()
  97.     lr = lr + 1
  98. end
  99.  
  100. --right is negative lr
  101. function oreright()
  102.     turtle.turnRight()
  103.     f1, f2 = turtle.inspect()
  104.     while f2.name ~= "minecraft:iron_ore" and u1 == false do
  105.         turtle.up()
  106.         u1, u2 = turtle.inspectUp()
  107.         f1, f2 = turtle.inspect()
  108.         ud = ud + 1
  109.     end
  110.     while f2.name ~= "minecraft:iron_ore" and d1 == false do
  111.         turtle.down()
  112.         d1, d2 = turtle.inspectDown()
  113.         f1, f2 = turtle.inspect()
  114.         ud = ud - 1
  115.     end
  116.     turtle.dig()
  117.     turtle.forward()
  118.     right = 0
  119.     turtle.turnLeft()
  120.     oreupdown()
  121.     lr = lr - 1
  122. end
  123.  
  124. function oreward()
  125.     turtle.dig()
  126.     turtle.forward()
  127.     breakorecheck()
  128.     f = f + 1
  129. end
  130.  
  131. function breakore()
  132.     f1, f2 = turtle.inspect()
  133.     d1, d2 = turtle.inspectDown()
  134.     u1, u2 = turtle.inspectUp()
  135.  
  136.     f = 0
  137.     lr = 0
  138.     ud = 0
  139.     orientation = 0
  140.     up = 0
  141.     down = 0
  142.     left = 0
  143.     right = 0
  144.     forward = 0
  145.     oreremaining = 1
  146.     inv = 0
  147.    
  148.     if f2.name == "minecraft:iron_ore" then
  149.         turtle.dig()
  150.         turtle.forward()
  151.         f = f + 1
  152.     elseif d2.name == "minecraft:iron_ore" then
  153.         turtle.digDown()
  154.         turtle.down()
  155.         udx = udx - 1
  156.     elseif u2.name == "minecraft:iron_ore" then
  157.         turtle.digUp()
  158.         turtle.up()
  159.         udx = udx + 1
  160.     end
  161.    
  162.     repeat
  163.         breakorecheck()
  164.         if up == 1 or down == 1 then
  165.             oreupdown()
  166.         end
  167.         repeat
  168.             oreleft()
  169.         until left == 0
  170.         turtle.turnRight()
  171.         while lr ~= 0 do
  172.             turtle.forward()
  173.             lr = lr - 1
  174.         end
  175.         turtle.turnLeft()
  176.         repeat  
  177.             oreright()
  178.         until right == 0
  179.         turtle.turnLeft()
  180.         while lr ~= 0 do
  181.             turtle.forward()
  182.             lr = lr + 1
  183.         end
  184.         turtle.turnRight()
  185.         resetvarsore()
  186.         oreward()
  187.        
  188.         if up + down + left + right + forward == 0 then
  189.             oreremaining = 0
  190.         end
  191.     until oreremaining == 0
  192.     if lr > 0 then
  193.         turtle.turnRight()
  194.         inv = 1
  195.     elseif lr < 0 then
  196.         turtle.turnLeft()
  197.         inv = -1
  198.     elseif lr == 0 then
  199.         shell.run("go right 2")
  200.     end
  201.     if inv ~= 0 then
  202.         for i = lr, 0, inv do
  203.             turtle.dig()
  204.             turtle.forward()
  205.         end
  206.     end
  207.     if inv == 1 then
  208.         turtle.turnRight()
  209.     elseif inv == -1 then
  210.         turtle.turnLeft()
  211.     end
  212.     while f ~= 0 do
  213.         turtle.dig()
  214.         turtle.forward()
  215.         f = f - 1
  216.     end
  217.     if udx > 0 then
  218.         turtle.digDown()
  219.         turtle.down()
  220.         udx = 0
  221.     elseif udx < 0 then
  222.         turtle.digUp()
  223.         turtle.up()
  224.     end
  225. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement