RandomShovel

[CC] Beta v1.1 Branch Miner

May 30th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.00 KB | None | 0 0
  1. ---------------------------
  2. ---    CONFIG SECTION   ---
  3. ---------------------------
  4.  
  5. fillOuterRing = true    -- Enables block filling ( Fills in gaps in the 3x3's walls )
  6. placeTorches = true    -- Enables torch placing on the LEFT side
  7. excavateStyle = true    -- Tunnels 3x3 then down 3x3 until it can't mine anymore
  8. tunnelXbyY = false    -- Tunnels 6x3 ( 3x3 -> Right -> 3x3 back -> Start )
  9. enderchestDump = false    -- Enables use of enderchest ( Slot 3 ) for dropping off items
  10. enderchestRefill = false    -- Enables use of enderchest ( Slot 4 ) for refueling
  11.    -- NOTE: WHEN USING ENDERCHESTS OPTIONS, TURTLE WON'T RETURN TO START UNTIL FINISHED --
  12. presetLength = 0    -- Tired of always putting in a length? Put the length here to make it stick to this program
  13. editablePreset = false    -- Decided you want to have X as your length, but you changed your mind this one time?
  14.  
  15. -----------------------
  16. ---    VARIABLES    ---
  17. -----------------------
  18.  
  19. local distance = 0
  20.  
  21.  
  22. ------------------------
  23. ---    Disclaimer    ---
  24. ------------------------
  25.  
  26. term.clear()
  27. term.setCursorPos(1, 1)
  28. print("WARNING: NOT FOR USE NEAR LAVA!")
  29. print("RANDOM INC IS NOT RESPONSIBLE FOR YOUR RESOURCES LOST!")
  30. print("PROGRAM MADE BY RANDOMSHOVEL!")
  31. print("USEABLE AS REFERENCE, NOT FOR REDISTRIBUTE!")
  32. print("CANNOT BE LOCATED SOMEWHERE OTHER THAN MY PASTEBIN PROFILE!")
  33. print("Press any button to continue")
  34. event,param1=os.pullEvent()
  35. if event == "key" then
  36.  term.clear()
  37.  term.setCursorPos(1, 1)
  38. end
  39. --------------------------------------------------------------------
  40. ---    Printing Info, Gathering Length, and Gathering Y Level    ---
  41. --------------------------------------------------------------------
  42.  
  43. print("Slots:")
  44. print("1) Torches")
  45. print("2) Building Material")
  46. print("3) EnderChest Dump Chest")
  47. print("4) EnderChest Refuel Chest")
  48. print("")
  49. print("VERSION 1.0")
  50. print("")
  51. print("Look through options before using!")
  52. print("")
  53. write("Enter Tunnel Lenth: ")
  54. length = tonumber(read())
  55.  
  56. if excavateStyle == true then
  57.  write("Enter Y Level Turtle Is On: ")
  58.  y = tonumber(read())
  59. end
  60.  
  61. ----------------------------------------------
  62. ---    Check Length, and Process Y Level   ---
  63. ----------------------------------------------
  64.  
  65. if length < 1 then
  66.  term.clear()
  67.  term.setCursorPos(1, 1)
  68.  print("Length must be greater than 1")
  69. elseif presetLength > 0 then
  70.  print("You have a preset length of "..presetLength)
  71.   if presetLength >= 0 and editablePreset == true then
  72.    print("You have editable preset enabled, you current preset is "..presetLength)
  73.    print("Multiply, Division, Addition, Subtraction")
  74.     write("Operation? ")
  75.     operation = read()
  76.     write("Number? ")
  77.     number = read()
  78.   end
  79.  
  80.    -------------------------
  81.    ---     Process Y     ---
  82.    -------------------------
  83.  
  84.    y = math.floor(y / 3)
  85.  
  86.  
  87.    -------------------------------
  88.    ---     Check Operation     ---
  89.    -------------------------------
  90.     if operation == "Multiply" or operation == "multiply" then
  91.      presetLength = presetLength * number
  92.     elseif operation == "Division" or operation == "division" then
  93.      presetLength = presetLength / number
  94.     elseif operation == "Addition" or operation == "addition" then
  95.      presetLength = presetLength + number
  96.     elseif operation == "Subtraction" or operation == "subtraction" then
  97.      presetLength = presetLength - number
  98.     end
  99. end
  100.  
  101. ---------------------------------
  102. ---    Essential Functions    ---
  103. ---------------------------------
  104.  
  105. function checkT()
  106.  turtle.select(1)
  107.   if turtle.getItemCount(1) == 0 and enderchestRefill == true then
  108.    turtle.select(4)
  109. turtle.place()
  110. turtle.select(1)
  111. turtle.suck(1)
  112. if turtle.getItemCount(1) > 0 then
  113.  turtle.select(4)
  114.  turtle.dig()
  115. elseif turtle.getItemCount(1) == 0 then
  116.  repeat
  117.   turtle.suck(1)
  118.  until turtle.getItemCount(1) > 0
  119.  turtle.select(4)
  120.  turtle.dig()
  121. end
  122.   end
  123. end
  124.  
  125. function turn()
  126.  turtle.turnLeft()
  127.  turtle.turnLeft()
  128. end
  129.  
  130. ----------------------------------
  131. ---    Chooseable Functions    ---
  132. ----------------------------------
  133.  
  134. function enderDump()
  135.  if enderchestDump == true then
  136.   turtle.select(3)
  137.   turtle.place()
  138.  for i=5,16 do
  139.   turtle.select(i)
  140.   turtle.drop()
  141.  end
  142.   turtle.select(3)
  143.   turtle.dig()
  144.  end
  145. end
  146.  
  147. function enderRefill()
  148.  if enderchestRefill == true then
  149.    cFuel = turtle.getFuelLevel()
  150.   if cFuel <= 100 then
  151.    turtle.select(4)
  152.    turtle.place()
  153.    turtle.suck()
  154.     fuel = turtle.getItemCount(4)
  155.    turtle.refuel(8)
  156.    turtle.select(4)
  157.    turtle.dig()
  158.    checkT()
  159.   end
  160.  end
  161. end
  162.  
  163. function torchPlacing()
  164.  distance = distance + 1
  165. if placeTorches == true then
  166.   if distance == 5 then
  167.    turtle.select(1)
  168.    turtle.up()
  169.    turtle.turnLeft()
  170.    turtle.place()
  171.    turtle.turnRight()
  172.    turtle.down()
  173.     distance = distance - 5
  174.   end
  175.  end
  176. end
  177.  
  178. function fillRing()
  179.  if fillOuterRing == true then
  180.  
  181.   repeat
  182.    turtle.down()
  183.   until turtle.down() == false
  184.  
  185.   turtle.turnRight()
  186.   turtle.select(2)
  187.   turtle.forward()
  188.   turtle.place()
  189.   turtle.placeDown()
  190.   turtle.up()
  191.   turtle.place()
  192.   turtle.up()
  193.   turtle.placeUp()
  194.   turtle.place()
  195.   turtle.back()
  196.   turtle.placeUp()
  197.   turtle.back()
  198.   turtle.placeUp()
  199.   turtle.turnLeft()
  200.   turtle.turnLeft()
  201.   turtle.place()
  202.   turtle.down()
  203.   turtle.place()
  204.   turtle.down()
  205.   turtle.place()
  206.   turtle.placeDown()
  207.   turtle.back()
  208.   turtle.placeDown()
  209.   turtle.turnRight()
  210.  end
  211. end
  212.  
  213. function home()
  214.  if excavateStyle == false then
  215.   turn()
  216.    for i=1, length do
  217.     turtle.forward()
  218.    end
  219.  elseif excavateStyle == true then
  220.   for i=1, down*3 do
  221.    turtle.digUp()
  222.    turtle.up()
  223.   end
  224.   if math.floor(down)/2 == 1 then
  225.    for i=1, length do
  226.     turtle.forward()
  227.    end
  228.   elseif math.floor(down)/2 == 2 then
  229.    turn()
  230.    for i=1, length do
  231.     turtle.forward()
  232.    end
  233.   end
  234. end
  235.  
  236. function emptyInventory()
  237.  if enderchestDump == false and enderchestRefill == false then
  238.   for i=3, 16 do
  239.    turtle.select(i)
  240.    turtle.drop()
  241.   end
  242.  elseif enderchestDump == true or enderchestRefill == true then
  243.   for i=5, 16 do
  244.    turtle.select(i)
  245.    turtle.drop()
  246.   end
  247.  end
  248. end
  249.  
  250. function digTunnel()
  251.  for i=1, 3 do
  252.   if i < 3 then
  253.    repeat
  254.     turtle.dig()
  255.    until turtle.dig() == false
  256.   end
  257.  end
  258. end
  259.  
  260.   turtle.turnLeft()
  261.  
  262.   repeat
  263.    turtle.dig()
  264.    sleep(0.5)
  265.   until turtle.dig() == false
  266.  
  267.   turn()
  268.  
  269.   repeat
  270.    turtle.dig()
  271.    sleep(0.5)
  272.   until turtle.dig() == false
  273.  
  274.   turtle.turnLeft()
  275.  
  276.   if i < 3 then
  277.    repeat
  278.     turtle.digUp()
  279.     sleep(0.5)
  280.    until turtle.digUp() == false  
  281.   end
  282.  
  283.   if i < 3 then
  284.    turtle.up()
  285.   end
  286.  
  287. end
  288.  
  289. function excavatingStyle()
  290.  for i = 1, y do
  291.   for l = 1, length do
  292.    digTunnel()
  293.    fillRing()
  294.    torchPlacing()
  295.    enderDump()
  296.    enderRefill()
  297.    if turtle.forward() == false then
  298.     repeat
  299.      turtle.dig()
  300.     until turtle.forward() == true
  301.    end
  302.   end
  303.  
  304.   turtle.back()
  305.  
  306.   for i=1, 3 do
  307.    turtle.digDown()
  308.    turtle.back()
  309.    turtle.digDown()
  310.    turtle.back()
  311.    turtle.digDown()
  312.    turtle.turnLeft()
  313.    turtle.forward()
  314.    turtle.turnRight()
  315.    turtle.digDown()
  316.    turtle.forward()
  317.    turtle.digDown()
  318.    turtle.forward()
  319.    turtle.digDown()
  320.    turtle.turnRight()
  321.    turtle.forward()
  322.    turtle.forward()
  323.    turtle.turnRight()
  324.    turtle.digDown()
  325.    turtle.forward()
  326.    turtle.digDown()
  327.    turtle.forward()
  328.    turtle.digDown()
  329.    turtle.turnRight()
  330.    turtle.forward()
  331.    turtle.turnLeft()
  332.    turtle.down()  
  333.   end
  334.   repeat
  335.    turtle.dig()
  336.   until turtle.dig() == false
  337.   turtle.forward()
  338.   down = down + 1
  339.  end
  340.  home()
  341.  emptyInventory()
  342. end
  343.  
  344. -------------------------
  345. ---     Main Code     ---
  346. -------------------------
  347.  
  348. if excavateStyle == false then
  349.  for l = 1, length do
  350.   digTunnel()
  351.   fillRing()
  352.   torchPlacing()
  353.   enderDump()
  354.   enderRefill()
  355.   if turtle.forward() == false then
  356.    repeat
  357.     turtle.dig()
  358.    until turtle.forward() == true
  359.   end
  360.  end
  361.  home()
  362.  emptyInventory()
  363. elseif excavateStyle == true then
  364.  excavatingStyle()
  365. end
Advertisement
Add Comment
Please, Sign In to add comment