Advertisement
banana111

stripShapeMiner

Nov 17th, 2020 (edited)
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.50 KB | None | 0 0
  1. shape = {2, -1, 10} --
  2.  
  3. banned_items = {"minecraft:dirt","chisel:basalt","minecraft:cobblestone", "minecraft:dirt", "minecraft:stone","minecraft:gravel","minecraft:flint"}
  4.  
  5. function Strip(a,b,c,d,e,f)
  6.     shape = {a,b,c}
  7.     print("starting stip mining")
  8.     Move(d, e, f)
  9.     turtle.turnRight()
  10.     turtle.dig()
  11.     turtle.select(15)
  12.     turtle.place()
  13.     turtle.turnLeft()
  14.     print("moved")
  15.     MineShape()
  16.     print("stoping shapemining")
  17.     Move(0,0,100)
  18.     print("moved")
  19.     TurnAround()
  20.     CheckDropBannedItems()
  21.     rednet.close()
  22.     print("stoping strip mining")
  23. end
  24.  
  25.  
  26.  
  27. function UpDownMine(x,y)
  28.     if y > 0 then
  29.        turtle.turnRight()
  30.        turtle.forward()
  31.        turtle.turnLeft()
  32.     end
  33.     if y < 0 then
  34.         turtle.turnLeft()
  35.         turtle.forward()
  36.         turtle.turnRight()
  37.     end
  38.    
  39.     if x > 0 then
  40.         turtle.digUp()
  41.         turtle.up()
  42.     end
  43.     if x < 0 then
  44.         turtle.digDown()
  45.         turtle.down()
  46.     end
  47. end
  48.  
  49.  
  50. function LeftRightCorner(x)
  51.     if x < 0 then
  52.         turtle.turnLeft()
  53.         turtle.dig()
  54.         turtle.forward()
  55.         turtle.turnLeft()
  56.     end
  57.     if x > 0 then
  58.         turtle.turnRight()
  59.         turtle.dig()
  60.         turtle.forward()
  61.         turtle.turnRight()
  62.     end
  63. end
  64.  
  65. function MineShape()
  66.     x = shape[1]
  67.     y = shape[2]
  68.     z = shape[3]
  69.     dir_x = 1
  70.     dir_y = 1
  71.     dir_z = 1
  72.     if x < 0 then
  73.         dir_x = -1
  74.         x = x * -1
  75.     end
  76.     if y < 0 then
  77.         dir_y = -1
  78.         y = y * -1
  79.     end
  80.     if z < 0 then
  81.         dir_z = -1
  82.         z = z * -1
  83.     end
  84.     if dir_z == -1 then
  85.         TurnAround()
  86.     end
  87.     for i=1,y do
  88.         for j=1,x do
  89.             for k=1,z do
  90.                 if k%10==0 then
  91.                     CheckDropBannedItems()
  92.                 end
  93.                 success, data = turtle.inspect()
  94.                 if data.name == "minecraft:wool" then
  95.                     return
  96.                 end
  97.                 turtle.dig()
  98.                 turtle.digUp()
  99.                 turtle.digDown()
  100.                 if i==y and j==1 then
  101.                     if k%5==0 then
  102.                         PlaceTorch()                        
  103.                     end
  104.                 end
  105.                 turtle.forward()
  106.             end
  107.         LeftRightCorner(dir_x)
  108.         dir_x = dir_x * -1    
  109.         end
  110.     CheckDropBannedItems()
  111.     dir_x = dir_x * -1
  112.     UpDownMine(dir_y, dir_x)
  113.     UpDownMine(dir_y, 0)
  114.     UpDownMine(dir_y, 0)
  115.     end
  116. end
  117.  
  118. function Move(x,y,z)
  119.     if x>0 then
  120.         turtle.turnRight()
  121.     elseif x<0 then
  122.         turtle.turnLeft()
  123.     end
  124.     for i=1,x do
  125.         CheckMine()
  126.     end
  127.     if x>0 then
  128.         turtle.turnLeft()
  129.     elseif x<0 then
  130.         turtle.turnRight()
  131.     end
  132.     if y>0 then
  133.         for i=1,y do
  134.             turtle.digUp()
  135.             turtle.up()
  136.         end    
  137.     elseif y<0 then
  138.         y= y*-1
  139.         for i=1,y do
  140.             turtle.digDown()
  141.             turtle.down()
  142.         end
  143.     end
  144.     if z<0 then
  145.         TurnAround()
  146.     end
  147.     for i=1,z do
  148.         success, data = turtle.inspect()
  149.         if data.name ~= nil then
  150.         end
  151.         if data.name == "minecraft:wool" then
  152.             return 0
  153.         else
  154.         turtle.dig()
  155.         turtle.forward()
  156.         end
  157.     end
  158. end
  159.  
  160. function CheckDropBannedItems()
  161.     for i=1,16 do
  162.         for j=1,table.getn(banned_items) do
  163.             if turtle.getItemDetail(i)~=nil then
  164.             if turtle.getItemDetail(i)["name"] == banned_items[j] then
  165.                 turtle.select(i)
  166.                 turtle.drop()
  167.             end
  168.             end
  169.         end
  170.     end
  171. end
  172.  
  173. function TurnAround()
  174.     turtle.turnLeft()
  175.     turtle.turnLeft()
  176. end
  177.  
  178. function Inspect()
  179.     success, data = turtle.inspect()
  180.     return data
  181. end
  182.  
  183. function CheckMine()
  184.     name = Inspect().name
  185.     while name == "computercraft:turtle_expanded" or name == "computercraft:turtle_advanced" do
  186.         name = Inspect().name
  187.     end
  188.     turtle.dig()
  189.     turtle.forward()
  190. end
  191.  
  192. function GoToStartRight(distance)
  193.     turtle.turnRight()
  194.     for i=0,distance do
  195.          MineMove()
  196.     end
  197.     turtle.turnLeft()
  198. end
  199.  
  200.  
  201. function MineMove ()
  202.     turtle.dig()
  203.     turtle.forward()
  204.     turtle.digUp()
  205.     turtle.digDown()
  206. end
  207.  
  208. function PlaceTorch()
  209.     turtle.select(16)
  210.     turtle.placeDown(1)
  211. end
  212.  
  213. function StripForward(distance, torch_distance)
  214.     for i=0,distance do
  215.         MineMove()
  216.         if torch_distance ~= 0 then
  217.             if i%torch_distance == 0 then
  218.                 PlaceTorch()
  219.             end
  220.         end
  221.         if i%30 == 0 then
  222.             CheckDropBannedItems()
  223.         end
  224.     end
  225. end
  226.  
  227. function MoveForward(distance)
  228.     for i=0,distance do
  229.         turtle.forward()
  230.     end
  231. end
  232.  
  233. function BreakDown(distance)
  234.     for i=1,distance do
  235.         turtle.digDown()
  236.         turtle.down()        
  237.     end
  238. end
  239.  
  240. function BreakUp(distance)
  241.     for i=1,distance do
  242.         turtle.digUp()
  243.         turtle.up()
  244.     end
  245. end
  246.  
  247. rednet.open("right")
  248. while rednet.isOpen() do
  249.     print("rednet opened")
  250.     local sender, message, protocol = rednet.receive()
  251.     if message[1] == "stop" then
  252.         rednet.close()
  253.         print("rednet stoped")
  254.     else
  255.         print(message[1],message[2],message[3],message[4],message[5],message[6])
  256.         Strip(message[1],message[2],message[3],message[4],message[5],message[6])
  257.         message={}
  258.         print()
  259.     end
  260. end
  261.  
  262. print(turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement