SHARE
TWEET

Untitled

a guest Aug 20th, 2019 121 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function itemIs(name)
  2.     if (turtle.getItemDetail() and turtle.getItemDetail().name == ("minecraft:" .. name)) then
  3.         if (name == "cobblestone") then
  4.             if (turtle.getItemCount() > 1) then
  5.                 return true
  6.             else
  7.                 return false
  8.             end
  9.         else
  10.             return true
  11.         end
  12.     else
  13.         return false
  14.     end
  15. end
  16.  
  17. function blockIs(name)
  18.     if (turtle.inspect() and turtle.inspect().name == ("minecraft:" .. name)) then
  19.         return true
  20.     else
  21.         return false
  22.     end
  23. end
  24.  
  25. function blockDownIs(name)
  26.     if (turtle.inspectDown() and turtle.inspectDown().name == ("minecraft:" .. name)) then
  27.         return true
  28.     else
  29.         return false
  30.     end
  31. end
  32.  
  33. function blockUpIs(name)
  34.     if (turtle.inspectUp() and turtle.inspectUp().name == ("minecraft:" .. name)) then
  35.         return true
  36.     else
  37.         return false
  38.     end
  39. end
  40.  
  41. function dig()
  42.     block = turtle.inspect()
  43.     if (blockIs("chest") or blockIs("hopper")) then
  44.         os.pullEvent("key")
  45.     end
  46.     turtle.dig()
  47. end
  48.  
  49. function fill()
  50.     turtle.select(2)
  51.     if (itemIs("cobblestone")) then
  52.         turtle.place()
  53.     end
  54. end
  55.  
  56. function fillDown()
  57.     turtle.select(2)
  58.     if (itemIs("cobblestone")) then
  59.         turtle.placeDown()
  60.     end
  61. end
  62.  
  63. function fillUp()
  64.     turtle.select(2)
  65.     if (itemIs("cobblestone")) then
  66.         turtle.placeUp()
  67.     end
  68. end
  69.  
  70. function forward()
  71.     refuel()
  72.     if (blockIs("lava") or blockIs("water")) then
  73.         fill()
  74.         turtle.dig()
  75.         turtle.forward()
  76.         if (blockUpIs("lava") or blockUpIs("water")) then
  77.             fillUp()
  78.         end
  79.         turtle.turnLeft()
  80.         if (blockIs("lava") or blockIs("water")) then
  81.             fill()
  82.         end
  83.         turtle.turnRight()
  84.         turtle.turnRight()
  85.         if (blockIs("lava") or blockIs("water")) then
  86.             fill()
  87.         end
  88.         turtle.turnLeft()
  89.     elseif (not turtle.foward()) then
  90.         if (blockIs("gravel") or blockIs("sand")) then
  91.             dig()
  92.             while (not turtle.forward()) do
  93.                 dig()
  94.             end
  95.         end
  96.     end
  97.     if (blockDownIs("lava") or blockDownIs("water")) then
  98.         turtle.select(2)
  99.         if (itemIs("cobblestone")) then
  100.             placeDown()
  101.         end
  102.     end
  103. end
  104.  
  105. function digShaft()
  106.     for i=1, shaftLength do
  107.         dig()
  108.         forward()
  109.         digUp()
  110.     end
  111. end
  112.  
  113. function digShaftWidth(n)
  114.     for j = 1, n do
  115.         for i = 1,4 do
  116.             dig()
  117.             forward()
  118.             digUp()
  119.         end
  120.     end
  121. end
  122.  
  123. function refuel()
  124.     if (turtle.getFuelLevel() < minimumFuel) then
  125.         for i=1,16 do
  126.             turtle.select(i)
  127.             if (itemIs("coal")) then
  128.                 while(turtle.getFuelLevel() < minimumFuel and turtle.getItemCount() > 0) do
  129.                     turtle.refuel(1)
  130.                 end
  131.             end
  132.         end
  133.     end
  134. end
  135.  
  136. function dropOff()
  137.     refuel()
  138.     for i=2,16 do
  139.         turtle.select(i)
  140.         if (i == 2) then
  141.             turtle.drop(turtle.getItemCount() - 1)
  142.         else
  143.             if (itemIs("coal")) then
  144.                 turtle.drop(32)
  145.             else
  146.                 turtle.drop()
  147.             end
  148.         end
  149.     end
  150. end
  151.        
  152. function stripMine(alreadyDone)
  153.     for i = 1+start, 6 do
  154.         if (i > 1) then
  155.             turtle.turnRight()
  156.             digShaftWidth(2*(i-1))
  157.             turtle.turnLeft()
  158.         end
  159.         digShaft()
  160.         turtle.turnRight()
  161.         digShaftWidth(1)
  162.         turtle.turnRight()
  163.         digShaft()
  164.         turtle.turnRight()
  165.         digShaftWidth(2*i - 1)
  166.         turtle.turnLeft()
  167.         dropOff()
  168.         turtle.turnLeft()
  169.         turtle.turnLeft()
  170.     end
  171. end
  172.  
  173. shaftLength = 200
  174. minimumFuel = 500
  175. stripMine(2)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top