Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.02 KB | None | 0 0
  1. --This is the standard 4 square mining setup
  2. --Designed to mine a 1x2x2 along with checking all 6 blocks adjacent to them for ores.
  3.  
  4. --Number of blocks you want to ignore
  5. local IgnoreSlots = 4
  6.  
  7. function digFwd()
  8.         if turtle.detect() then
  9.                 while not turtle.dig() do
  10.                         sleep(.5)
  11.                 end
  12.                 return true
  13.         else
  14.                 print("No block forward")
  15.                 return false
  16.         end
  17. end
  18.  
  19. function digUp()
  20.         if turtle.detectUp() then
  21.                 while not turtle.digUp() do
  22.                         sleep(.5)
  23.                 end
  24.                 return true
  25.         else
  26.                 print("No block up")
  27.                 return false
  28.         end
  29. end
  30.  
  31. function digDown()
  32.         if turtle.detectDown() then
  33.                 while not turtle.digDown() do
  34.                         sleep(.5)
  35.                 end
  36.                 return true
  37.         else
  38.                 print("No block down")
  39.                 return false
  40.         end
  41. end
  42.  
  43.  
  44. local function moveFwd()
  45.         if turtle.detect() == false then
  46.                 while not turtle.forward() do
  47.                         sleep(.5)
  48.                 end
  49.         end
  50. end
  51.  
  52. local function moveUp()
  53.         if turtle.detectUp() == false then
  54.                 while not turtle.Up() do
  55.                         sleep(.5)
  56.                 end
  57.         end
  58. end
  59.  
  60. local function moveDown()
  61.         if turtle.detectDown() == false then
  62.                 while not turtle.Down() do
  63.                         sleep(.5)
  64.                 end
  65.         end
  66. end
  67.  
  68. local function Refuel()
  69.         if turtle.getFuelLevel() < 10 then
  70.                 turtle.select(16)
  71.                 return turtle.refuel(10)
  72.         else
  73.                 return true
  74.         end
  75. end
  76.  
  77. local function DepositChest()
  78.         print("Depositing the Load...")
  79.         for i = IgnoreSlots + 1,15 do
  80.                 turtle.select(i)
  81.                 turtle.drop()
  82.         end
  83. end
  84.  
  85. local function checkFwd()
  86.         TimesChecked = 0
  87.         for i = 1,tonumber(IgnoreSlots) do
  88.                 turtle.select(i)
  89.                 if turtle.compare() == false then
  90.                         TimesChecked = TimesChecked + 1
  91.                         if TimesChecked == IgnoreSlots then
  92.                                 digFwd()
  93.                         end
  94.                 else
  95.                         return
  96.                 end
  97.         end
  98. end
  99.  
  100. local function checkDown()
  101.         TimesChecked = 0
  102.         for i = 1,tonumber(IgnoreSlots) do
  103.                 turtle.select(i)
  104.                 if turtle.compareDown() == false then
  105.                         TimesChecked = TimesChecked + 1
  106.                         if TimesChecked == IgnoreSlots then
  107.                                 digDown()
  108.                         end
  109.                 else
  110.                         return
  111.                 end
  112.         end
  113. end
  114.  
  115. local function checkUp()
  116.         TimesChecked = 0
  117.         for i = 1,tonumber(IgnoreSlots) do
  118.                 turtle.select(i)
  119.                 if turtle.compareUp() == false then
  120.                         TimesChecked = TimesChecked + 1
  121.                         if TimesChecked == IgnoreSlots then
  122.                                 digUp()
  123.                         end
  124.                 else
  125.                         return
  126.                 end
  127.         end
  128. end
  129.  
  130. local function checkLeft()
  131.         turtle.turnLeft()
  132.         checkFwd()
  133.         turtle.turnRight()
  134. end
  135.  
  136. local function checkRight()
  137.         turtle.turnRight()
  138.         checkFwd()
  139.         turtle.turnLeft()
  140. end
  141.  
  142. local function checkSides()
  143.         checkLeft()
  144.         checkRight()
  145. end
  146.  
  147. local function rodeoMine(turns)
  148.     for i=1,turns do
  149.             checkFwd()
  150.             moveFwd()
  151.             checkSides()
  152.             checkDown()
  153.             checkUp()
  154.             moveUp()
  155.             checkSides()
  156.             checkUp()
  157.             checkFwd()
  158.             moveFwd()
  159.             checkSides()
  160.             checkUp()
  161.             checkDown()
  162.             moveDown()
  163.     end
  164. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement