ThSchm

Untitled

Aug 17th, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local tArgs = { ... }
  2.  
  3. local digDownAmount
  4. local digDeepAmount
  5. local stripeAmount
  6.  
  7. if not (#tArgs == 3) then
  8.   print ("You need exactly three parameter!")
  9.   return
  10. else
  11.   digDownAmount = tonumber(tArgs[1])
  12.   digDeepAmount = tonumber(tArgs[2])
  13.   stripeAmount = tonumber(tArgs[3])
  14. end
  15.  
  16. local function forward()
  17.   while not turtle.forward() do
  18.     if not turtle.dig() then
  19.       turtle.attack()
  20.       sleep(0.5)
  21.     end
  22.   end
  23. end
  24.  
  25. local fucntion up()
  26.   while not turtle.up() do
  27.     if not turtle.digUp() then
  28.       turtle.attackUp()
  29.       sleep(0.5)
  30.     end
  31.   end
  32. end
  33.  
  34. local function down()
  35.   while not turtle.down() do
  36.     if not turtle.digDown() then
  37.       turtle.attackDown()
  38.       sleep(0.5)
  39.     end
  40.   end
  41. end
  42.  
  43. local function FindChest()
  44.   local turns = 0
  45.   local chestFound = false
  46.   while not ChestFound do
  47.     for i = 1, 4 do
  48.       if turtle.detect() then
  49.         print("Chest found... starting mine operation!")
  50.         ChestFound = true
  51.         break
  52.       else
  53.         turtle.turnRight()
  54.       end
  55.     end
  56.     print("No Chest found.. place a chest near turtle to start mining")
  57.     sleep(3)
  58.   end
  59. end
  60.  
  61. local function mineToBase(amount)
  62.   turtle.select(1)
  63.   for i = 1, amount do
  64.     down()
  65.     turtle.placeUp()
  66.   end
  67. end
  68.  
  69. local function moveToTop(amount)
  70.   turtle.select(1)
  71.   for i = 1, amount do
  72.     up()
  73.     turtle.placeDown()
  74.   end
  75. end
  76.  
  77. local function DigRow()
  78.   turtle.dig()
  79.   forward()
  80.   turtle.digDown()
  81.   turtle.digUp()      
  82. end
  83.  
  84. local function EmptyInventory()
  85.   for i = 1, 16 do
  86.     turtle.select(i)
  87.     turtle.drop()
  88.   end
  89. end
  90.  
  91. local function FirstMining(amount)
  92.   for i = 1, amount do
  93.     DigRow()
  94.   end
  95.  
  96.   turtle.turnLeft()
  97.   turtle.turnLeft()
  98.   for i = 1, amount do
  99.     forward()
  100.   end  
  101.   turtle.turnLeft()
  102.   turtle.turnLeft()
  103. end
  104.  
  105. local function MiningLoop(amount)
  106.   for i = 1, amount do
  107.     FirstMining(digDeepAmount)
  108.  
  109.     turtle.turnRight()
  110.     for i = 1, 2 do
  111.         turtle.dig()
  112.         forward()
  113.     end
  114.     turtle.turnLeft()
  115.   end
  116.  
  117.   turtle.turnLeft()
  118.   for i = 1, amount * 3 do
  119.     forward()
  120.   end
  121.   turtle.turnRight()
  122. end
  123.  
  124. FindChest()
  125. mineToBase(digDownAmount)
  126. MiningLoop(stripeAmount)
  127. moveToTop(digDownAmount)
  128. EmptyInventory()
  129. print ("Run successfully!")
Advertisement
Add Comment
Please, Sign In to add comment