Advertisement
tomte55

CC Mine

Oct 18th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.47 KB | None | 0 0
  1. --Put 1 Gravel in slot 1
  2. --Put an ender chest in slot 2
  3. --Put torches in slot 15
  4. --Put fuel in slot 16
  5.  
  6. --When you start the program put in the lenght of each shaft and how many shafts you want.
  7. --And it checks for gravel so it doesn't screw up the shafts
  8.  
  9.  
  10.  local newDistQ = 0
  11.  
  12.  
  13. local lenght = 0
  14. local quest = 0
  15. local mineL = 0
  16. local shafts = 0
  17. local shaftsQ = 0
  18. local newDist = 0
  19.  
  20. function fuel()
  21.   if turtle.getFuelLevel() <= 10 then
  22.     turtle.select(16)
  23.     turtle.refuel(1)
  24.   end
  25. end
  26.  
  27. function clear()
  28.   term.clear()
  29.   term.setCursorPos(1,1)
  30. end
  31.  
  32. function start()
  33.   clear()
  34.   print("Lenght of each shaft?")
  35.   quest = tonumber(read())
  36.   if quest>50 then --This is because the inventory size
  37.     print("Not more than 50")
  38.     quest = tonumber(read())
  39.   end
  40.   clear()
  41.   print("Number of shafts?")
  42.   print("Only put 2,4,6,8 etc")
  43.   shaftsQ = tonumber(read())
  44.   clear()
  45.   print("Lenght between shafts?")
  46.   newDistQ = tonumber(read())
  47.   mine()
  48.  
  49. end
  50.  
  51. function isGravel()
  52.   turtle.select(1)
  53.   while turtle.compare() == true do
  54.     turtle.dig()
  55.     sleep(1)
  56.   end
  57.   while turtle.compareUp() == true do
  58.     turtle.digUp()
  59.     sleep(1)
  60.   end
  61. end
  62.  
  63. function newMine()
  64.   print("newMine()")
  65.   newDist = 0
  66.   mineL = mineL + 1
  67.   if mineL%2==0 then
  68.     turtle.turnRight()
  69.     else do
  70.     turtle.turnLeft()
  71.     end
  72.   end
  73.   while newDist ~= newDistQ do
  74.     isGravel()
  75.     turtle.dig()
  76.     isGravel()
  77.     turtle.forward()
  78.     newDist = newDist + 1
  79.     isGravel()
  80.     turtle.digDown()
  81.     turtle.digUp()
  82.   end
  83.   if newDist == newDistQ and mineL%2==0 then
  84.     turtle.turnRight()
  85.     mine()
  86.   end
  87.   if newDist == newDistQ then
  88.     turtle.turnLeft()
  89.     mine()
  90.   end
  91. end
  92.  
  93. function chestDrop()
  94.   shafts = shafts + 1
  95.   turtle.turnLeft()
  96.   turtle.turnLeft()
  97.   turtle.select(2)
  98.   turtle.place()
  99.   for i=3,14 do
  100.     turtle.select(i)
  101.     turtle.drop()
  102.   end
  103.   turtle.select(2)
  104.   turtle.dig()
  105.   turtle.turnLeft()
  106.   turtle.turnLeft()
  107.   if shafts == shaftsQ then
  108.     os.reboot()
  109.   end
  110.   newMine()
  111. end
  112.  
  113. function mine()
  114.   lenght = 0
  115.   while lenght ~= quest do
  116.     fuel()
  117.     isGravel()
  118.     turtle.dig()
  119.     isGravel()
  120.     turtle.forward()
  121.     lenght = lenght + 1
  122.     isGravel()
  123.     turtle.digUp()
  124.     turtle.digDown()
  125.     if lenght%10==0 then
  126.       turtle.select(15)
  127.       turtle.placeDown()
  128.     end
  129.     if lenght == quest then
  130.       chestDrop()
  131.     end
  132.   end
  133. end
  134.  
  135.  
  136. -- ( Main Stuff ) --
  137.  
  138. turtle.up()
  139. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement