ChemE

DigGeode

Nov 20th, 2013
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.95 KB | None | 0 0
  1. local minFuel = 875
  2. local i=0
  3.  
  4. local function ClearTerminal()
  5.   term.clear()
  6.   term.setCursorPos(1,1)
  7. end
  8.  
  9. local function AssureInv()
  10.   if turtle.getItemCount(15)>0 then
  11.     turtle.digDown()
  12.     turtle.select(16)
  13.     turtle.placeDown()
  14.     for i=1,15,1 do
  15.       turtle.select(i)
  16.       turtle.dropDown()
  17.     end
  18.     turtle.select(16)
  19.     turtle.digDown()
  20.     --turtle.select(1)
  21.   end
  22. end
  23.  
  24. local function DigForward(count)
  25.   for i=1,count,1 do
  26.     AssureInv()
  27.     turtle.dig()
  28.     while turtle.forward()==false do
  29.       turtle.dig()
  30.       turtle.attack()
  31.       sleep(0.05)
  32.     end
  33.     turtle.digUp()
  34.     turtle.digDown()
  35.   end
  36. end
  37.  
  38. local function RightFace()
  39.   turtle.turnRight()
  40.   DigForward(1)
  41.   turtle.turnRight()
  42. end
  43.  
  44. local function LeftFace()
  45.   turtle.turnLeft()
  46.   DigForward(1)
  47.   turtle.turnLeft()
  48. end
  49.  
  50. local function GoUp()
  51.   for i=1,3,1 do
  52.     while turtle.up()==false do
  53.       turtle.attackUp()
  54.       turtle.digUp()
  55.     end
  56.   end
  57.   turtle.digUp()
  58. end
  59.  
  60. local function DigTierOne()
  61.   --Dig down to starting position
  62.   turtle.digDown()
  63.   turtle.down()
  64.   turtle.digDown()
  65.   turtle.down()
  66.   turtle.digDown()
  67.   turtle.down()
  68.   turtle.digDown()
  69.   turtle.up()
  70.   DigForward(6)
  71.   RightFace()
  72.   DigForward(12)
  73.   turtle.back()
  74.   LeftFace()
  75.   DigForward(10)
  76.   RightFace()
  77.   DigForward(10)
  78.   turtle.back()
  79.   LeftFace()
  80.   DigForward(8)
  81.   turtle.back()
  82.   RightFace()
  83.   DigForward(6)
  84.   turtle.back()
  85.   turtle.back()
  86.   LeftFace()
  87.   DigForward(2)
  88.   turtle.back()
  89.   turtle.turnLeft()
  90.   DigForward(6)
  91.   turtle.turnLeft()
  92.   DigForward(6)
  93.   RightFace()
  94.   DigForward(12)
  95.   turtle.back()
  96.   LeftFace()
  97.   DigForward(10)
  98.   RightFace()
  99.   DigForward(10)
  100.   turtle.back()
  101.   LeftFace()
  102.   DigForward(8)
  103.   turtle.back()
  104.   RightFace()
  105.   DigForward(6)
  106.   turtle.back()
  107.   turtle.back()
  108.   LeftFace()
  109.   DigForward(2)
  110.   RightFace()
  111.   GoUp()
  112. end
  113.  
  114. local function DigTierTwo()
  115.   --Row 1
  116.   DigForward(4)
  117.   turtle.turnRight()
  118.   turtle.turnRight()
  119.   DigForward(7)
  120.  
  121.   --Row 2
  122.   LeftFace()
  123.   DigForward(9)
  124.  
  125.   --Row 3
  126.   RightFace()
  127.   DigForward(11)
  128.  
  129.   --Row 4
  130.   LeftFace()
  131.   DigForward(13)
  132.  
  133.   --Row 5
  134.   RightFace()
  135.   DigForward(14)
  136.  
  137.   --Row 6
  138.   LeftFace()
  139.   DigForward(14)
  140.  
  141.   --Row 7
  142.   RightFace()
  143.   DigForward(14)
  144.  
  145.   --Row 8
  146.   LeftFace()
  147.   DigForward(14)
  148.  
  149.   --Row 9
  150.   RightFace()
  151.   DigForward(14)
  152.  
  153.   --Row 10
  154.   LeftFace()
  155.   DigForward(14)
  156.  
  157.   --Row 11
  158.   RightFace()
  159.   DigForward(14)
  160.   turtle.back()
  161.  
  162.   --Row 12
  163.   LeftFace()
  164.   DigForward(12)
  165.   turtle.back()
  166.  
  167.   --Row 13
  168.   RightFace()
  169.   DigForward(10)
  170.   turtle.back()
  171.  
  172.   --Row 14
  173.   LeftFace()
  174.   DigForward(8)
  175.   turtle.back()
  176.  
  177.   --Row 15
  178.   RightFace()
  179.   DigForward(6)
  180. end
  181.  
  182. local function DigTierThree()
  183.   turtle.turnLeft()
  184.   turtle.turnLeft()
  185.   DigForward(8)
  186.   LeftFace()
  187.   DigForward(11)
  188.   RightFace()
  189.   DigForward(12)
  190.   LeftFace()
  191.   DigForward(13)
  192.   RightFace()
  193.   DigForward(14)
  194.   LeftFace()
  195.   DigForward(14)
  196.   RightFace()
  197.   DigForward(14)
  198.  
  199.   --Get the sole abyssal block projecting in the -x direction
  200.   turtle.turnLeft()
  201.   DigForward(1)
  202.   turtle.turnRight()
  203.   turtle.dig()
  204.   turtle.turnLeft()
  205.   turtle.turnLeft()
  206.   DigForward(14)
  207.   RightFace()
  208.   DigForward(14)
  209.   LeftFace()
  210.   DigForward(14)
  211.   RightFace()
  212.   DigForward(14)
  213.   turtle.back()
  214.   LeftFace()
  215.   DigForward(12)
  216.   RightFace()
  217.   DigForward(12)
  218.   turtle.back()
  219.   LeftFace()
  220.   DigForward(10)
  221.   turtle.back()
  222.   turtle.back()
  223.   RightFace()
  224.   DigForward(3)
  225.   turtle.turnLeft()
  226.   turtle.dig()
  227.   turtle.turnRight()
  228.   DigForward(3)
  229. end
  230.  
  231. local function DigTierFour()
  232.   turtle.turnLeft()
  233.   turtle.turnLeft()
  234.   DigForward(7)
  235.   LeftFace()
  236.   DigForward(9)
  237.   RightFace()
  238.   DigForward(11)
  239.   LeftFace()
  240.   DigForward(13)
  241.   RightFace()
  242.   DigForward(14)
  243.   LeftFace()
  244.   DigForward(14)
  245.   RightFace()
  246.   DigForward(14)
  247.   LeftFace()
  248.   DigForward(14)
  249.   RightFace()
  250.   DigForward(14)
  251.   LeftFace()
  252.   DigForward(14)
  253.   RightFace()
  254.   DigForward(14)
  255.   turtle.back()
  256.   LeftFace()
  257.   DigForward(12)
  258.   turtle.back()
  259.   RightFace()
  260.   DigForward(10)
  261.   turtle.back()
  262.   LeftFace()
  263.   DigForward(8)
  264.   turtle.back()
  265.   RightFace()
  266.   DigForward(6)
  267. end
  268.  
  269. local function MoveToTierFive()
  270.   turtle.back()
  271.   turtle.back()
  272.   turtle.turnLeft()
  273.   turtle.back()
  274.   turtle.turnLeft()
  275.   GoUp()
  276. end
  277.  
  278. local function DigTierFive()
  279.   DigForward(4)
  280.   LeftFace()
  281.   DigForward(7)
  282.   RightFace()
  283.   DigForward(9)
  284.   LeftFace()
  285.   DigForward(10)
  286.   RightFace()
  287.   DigForward(11)
  288.   LeftFace()
  289.   DigForward(12)
  290.   RightFace()
  291.   DigForward(12)
  292.   LeftFace()
  293.   DigForward(12)
  294.   turtle.back()
  295.   RightFace()
  296.   DigForward(10)
  297.   LeftFace()
  298.   DigForward(10)
  299.   turtle.back()
  300.   RightFace()
  301.   DigForward(8)
  302.   turtle.back()
  303.   LeftFace()
  304.   DigForward(6)
  305.   turtle.back()
  306.   turtle.back()
  307.   RightFace()
  308.   DigForward(2)
  309. end
  310.  
  311. local function FinalDump()
  312.   turtle.select(16)
  313.   turtle.placeDown()
  314.   for i=1,15,1 do
  315.     turtle.select(i)
  316.     turtle.dropDown()
  317.   end
  318.   turtle.select(16)
  319.   turtle.digDown()
  320. end
  321.  
  322. --=========== Main Program ===========
  323. --Make sure we have enough fuel to begin
  324. ClearTerminal()
  325. if turtle.getFuelLevel()<minFuel then
  326.   print("WARNING: Insufficient fuel; please add fuel to slot 1")
  327. end
  328. turtle.select(1)
  329. while turtle.getFuelLevel()<minFuel do
  330.   if turtle.refuel()==true then
  331.     print("Fuel level now " .. turtle.getFuelLevel() .. " of " .. minFuel .. " needed")
  332.   end  
  333.   sleep(0.1)
  334. end
  335.  
  336. --Make sure we have an ender chest to
  337. --route material back to our base
  338. if turtle.getItemCount(16)~=1 then
  339.   print("Place an ender chest in slot 16")
  340. end
  341. while turtle.getItemCount(16)~=1 do
  342.   sleep(0.1)
  343. end
  344.  
  345. --Proceed with the geode mining
  346. ClearTerminal()
  347. print("Digging geode, check back in 22 minutes")
  348. print("Initial fuel level is " .. turtle.getFuelLevel())
  349. DigTierOne()
  350. DigTierTwo()
  351. GoUp()
  352. DigTierThree()
  353. GoUp()
  354. DigTierFour()
  355. MoveToTierFive()
  356. DigTierFive()
  357. FinalDump()
  358. print("Final fuel level is " .. turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment