grand_mind1

Turtle Strip mine

May 18th, 2013
2,369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.18 KB | None | 0 0
  1. function forward(forw, threeTall)
  2.   if forw == nil then
  3.     forw = 1
  4.   end
  5.   for o = 1,forw do
  6.     while not turtle.forward() do
  7.       turtle.dig()
  8.       turtle.attack()
  9.     end
  10.     if inMainTunnel == true then
  11.       totforw = totforw+1
  12.     end
  13.     print(totforw)
  14.     if threeTall == true then
  15.       turtle.digUp()
  16.       turtle.digDown()
  17.     elseif threeTall == false and bridge == "y" then
  18.       if not turtle.detectDown() then
  19.         turtle.select(14)
  20.         turtle.placeDown()
  21.         turtle.select(1)
  22.       end
  23.     end
  24.   end
  25. end
  26.  
  27.  
  28. function torch()
  29.     if torches ~= "n" then
  30.     turtle.select(tonumber(torches))
  31.     turtle.dig()
  32.     turtle.place()
  33.     turtle.select(1)
  34.   end
  35. end
  36.  
  37. function dropoff(side)
  38.   for p = 1,max do
  39.     turtle.select(p)
  40.     if side == "down" then  
  41.       turtle.dropDown()
  42.     elseif side == "front" then
  43.       turtle.drop()
  44.     end
  45.   end
  46.   turtle.select(1)
  47. end
  48.  
  49. function placeChest()
  50.   if chest == "chests" then
  51.     turtle.down()
  52.     turtle.digDown()
  53.     turtle.select(chests)
  54.     turtle.placeDown()
  55.     dropoff()
  56.     turtle.select(1)
  57.     turtle.up()
  58.   elseif chest == "enderchest" then
  59.     turtle.digDown()
  60.     turtle.select(ender)
  61.     turtle.placeDown()
  62.     dropoff()
  63.     turtle.digDown()
  64.     turtle.select(1)
  65.     turtle.up()
  66.   elseif chest == "d" then
  67.     turtle.turnLeft()
  68.     turtle.turnLeft()
  69.     inMainTunnel = false
  70.     forward(totforw)
  71.     turtle.turnRight()
  72.     dropoff("front")
  73.     turtle.turnRight()
  74.     forward(totforw)
  75.   end
  76. end
  77.  
  78. function refuel()
  79.   if turtle.getFuelLevel() <= 10 then
  80.     for i = 1,max-1 do
  81.       turtle.select(i)
  82.       if turtle.refuel() then
  83.         break
  84.       end
  85.     end
  86.   end
  87. end
  88. curlen = 1
  89. totforw = 0
  90. max = 16
  91.  
  92. write("Length of main tunnel: ")
  93. tunlen = tonumber(read())
  94. write("Length of branch: ")
  95. branlen = tonumber(read())
  96. write("Space between branches: ")
  97. space = tonumber(read())
  98. term.clear()
  99. term.setCursorPos(1,1)
  100. print("Would you like torches to be place?")
  101. print("If so, type 'y'")
  102. print("If not, type 'n'")
  103. torches = read()
  104. term.clear()
  105. term.setCursorPos(1, 1)
  106. print("Would you like me to dropoff items in chests?")
  107. print("If you would like normal chests, type 'chests'.")
  108. print("If you would like enderchests, type 'enderchest'.")
  109. print("If placing blocks with turtles is disabled and you still want chests,")
  110. print("type 'd' and place a chest to the left of the turtle.")
  111. print("If you would not like chests to placed, type 'n'")
  112. print("Warning: Not using chests will most likely result in lost resources!")
  113. chest = read()
  114. term.clear()
  115. term.setCursorPos(1, 1)
  116. print("Would you like me to bridge over")
  117. print("holes, water, and lava?")
  118. print("If so, type 'y'")
  119. print("If not, type 'n'")
  120. bridge = read()
  121.  
  122. term.clear()
  123. term.setCursorPos(1,1)
  124.  
  125. if chest ~= "d" then
  126.   print("Please place your "..chest.." in slot 16")
  127.   while turtle.getItemCount(16) == 0 do
  128.     sleep(1)
  129.   end
  130.   max = max-1
  131. end
  132.  
  133. term.clear()
  134. term.setCursorPos(1, 1)
  135.  
  136. if torches == "y" then
  137.   print("Please place torches in slot 15...")
  138.   while turtle.getItemCount(15) == 0 do
  139.     sleep(1)
  140.   end
  141.   max = max-1
  142. end
  143.  
  144. term.clear()
  145. term.setCursorPos(1, 1)
  146.  
  147. if bridge == "y" then
  148.   print("Please place bridging material in slot 14")
  149.   while turtle.getItemCount(14) == 0 do
  150.     sleep(1)
  151.   end
  152.   max = max-1
  153. end
  154.  
  155. term.clear()
  156. term.setCursorPos(1, 1)
  157. textutils.slowPrint("Begining strip mine...")
  158. print(max)
  159.  
  160. for i = curlen,tunlen do
  161.   inMainTunnel = true
  162.   if turtle.getItemCount(max) > 0 then
  163.     placeChest()
  164.   end  
  165.   inMainTunnel = true
  166.   forward(space+1, true)
  167.   turtle.turnLeft()
  168.   inMainTunnel = false
  169.   forward(branlen, true)
  170.   torch()
  171.   turtle.turnLeft()
  172.   turtle.turnLeft()
  173.   turtle.down()
  174.   forward(branlen, false)
  175.   turtle.up()
  176.   forward(branlen, true)
  177.   torch()
  178.   turtle.turnLeft()
  179.   turtle.turnLeft()
  180.   turtle.down()
  181.   forward(branlen, false)
  182.   inMainTunnel = true
  183.   turtle.turnRight()
  184.   turtle.up()
  185.   refuel()
  186. end
  187.  
  188. turtle.turnRight()
  189. turtle.turnRight()
  190. turtle.down()
  191. forward(totforw, false)
  192. turtle.up()
  193. if chest == "d" then
  194.   turtle.turnRight()
  195.   dropoff()
  196.   turtle.turnLeft()
  197. end
  198. textutils.slowPrint("Mining operation completed!")
Advertisement
Add Comment
Please, Sign In to add comment