Guest User

Stripminer

a guest
Aug 16th, 2014
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.66 KB | None | 0 0
  1. local tArgs = { ... }
  2.  
  3. local digDownAmount
  4. local digDeepAmount
  5. local stripeAmount
  6.  
  7. local chestSlot = 2
  8.  
  9. if not (#tArgs == 3) then
  10.   print ("You need exactly three parameter!")
  11.   return
  12. else
  13.   digDownAmount = tonumber(tArgs[1])
  14.   digDeepAmount = tonumber(tArgs[2])
  15.   stripeAmount = tonumber(tArgs[3])
  16. end
  17.  
  18. local function mineToBase(amount)
  19.   for i = 1, amount do
  20.     while not turtle.down() do
  21.     turtle.digDown()
  22.     end
  23.   end
  24. end
  25.  
  26. local function moveToTop(amount)
  27.   for i = 1, amount do
  28.     while not turtle.up() do
  29.     turtle.digUp()
  30.     end
  31.   end
  32. end
  33.  
  34. local function PlaceChest()
  35.   print ("PlaceChest called...")
  36.   turtle.select(chestSlot)
  37.   while true do
  38.     if (turtle.getItemCount(chestSlot) == 1) and (turtle.place()) or (turtle.dig() and turtle.place()) then
  39.       print("Chest successfully placed!")
  40.       break
  41.     else
  42.       print("Chest placing error!")
  43.       sleep(1)
  44.     end      
  45.   end
  46.   turtle.turnRight()
  47.   turtle.turnRight()
  48. end
  49.  
  50. local function DigRow()
  51.   turtle.dig()
  52.   while not turtle.forward() do
  53.     sleep(1)
  54.   end
  55.   turtle.digDown()
  56.   turtle.digUp()      
  57. end
  58.  
  59. local function EmptyInventory()
  60.   for i = 1, 16 do
  61.     turtle.select(i)
  62.     turtle.drop()
  63.   end
  64. end
  65.  
  66. local function FirstMining(amount)
  67.   for i = 1, amount do
  68.     DigRow()
  69.   end
  70.  
  71.   turtle.turnLeft()
  72.   turtle.turnLeft()
  73.   for i = 1, amount do
  74.     while not turtle.forward() do
  75.     if turtle.dig() then
  76.       turtle.forward()
  77.       break
  78.     end
  79.     sleep(1)
  80.     end
  81.   end
  82.  
  83.   EmptyInventory()
  84.  
  85.   turtle.turnLeft()
  86.   turtle.turnLeft()
  87. end
  88.  
  89. local function PickUpEnderChest()
  90.   turtle.select(chestSlot)
  91.   local turns = 0
  92.     while true do
  93.     if turtle.detect() then
  94.       turtle.dig()
  95.       break
  96.     end
  97.     turtle.turnRight()
  98.     turns = turns + 1
  99.     if (turns == 4) then
  100.       turns = 0
  101.       print("No chest detected.. waiting")
  102.       sleep(5)
  103.     end    
  104.   end  
  105. end
  106.  
  107. local function PlaceEnderChest()
  108.   turtle.select(chestSlot)
  109.   while true do
  110.     if not turtle.place() then
  111.       print("Cannot place chest for ending, waiting...")
  112.       sleep(5)
  113.     else
  114.       break
  115.     end
  116.   end
  117. end
  118.  
  119. local function GetChest()
  120.   turtle.turnLeft()
  121.   turtle.turnLeft()
  122.   turtle.select(chestSlot)
  123.   turtle.dig()
  124. end
  125.  
  126. local function MiningLoop(amount)
  127.   for i = 1, amount do
  128.     PlaceChest()
  129.     FirstMining(digDeepAmount)
  130.     GetChest()
  131.  
  132.     turtle.turnRight()
  133.     for i = 1, 2 do
  134.         turtle.dig()
  135.         turtle.forward()
  136.     end
  137.     turtle.turnLeft()
  138.   end
  139. end
  140.  
  141. PickUpEnderChest()
  142. mineToBase(digDownAmount)
  143. MiningLoop(stripeAmount)
  144. moveToTop(digDownAmount)
  145. PlaceEnderChest()
  146. print ("Run successfully!")
Advertisement
Add Comment
Please, Sign In to add comment