Advertisement
JJC15433

Branch Mine Main Corridor 3x3

Jun 25th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.39 KB | None | 0 0
  1. --Branch Mine Main Corridor
  2.  
  3. --Slots
  4. ---12, 13: Blocks
  5. ---14, 15: Torches
  6. ---16: Fuel
  7.  
  8. --Declaring Variables
  9. local distance = 0
  10. local n = 0
  11.  
  12. --Declaring Functions
  13. function dig()
  14.     while turtle.detect() do
  15.         turtle.dig()
  16.     end
  17.     turtle.forward()
  18.     turtle.digDown()
  19.     while turtle.detectUp() do
  20.         turtle.digUp()
  21.     end
  22. end
  23.  
  24. function torch()
  25.     turtle.select(14)
  26.     if turtle.getItemCount(14) == 0 then
  27.         turtle.select(15)
  28.     end
  29.     turtle.turnRight()
  30.     turtle.turnRight()
  31.     turtle.place()
  32.     turtle.turnRight()
  33.     turtle.turnRight()
  34. end
  35.  
  36. function fuel()
  37.     if turtle.getFuelLevel() <= 50 then
  38.         turtle.select(16)
  39.         turtle.refuel(5)
  40.     end
  41. end
  42.  
  43. function block()
  44.     turtle.select(13)
  45.     if turtle.getItemCount(13) == 0 then
  46.         turtle.select(14)
  47.     end
  48. end
  49.  
  50. function placeblockforward()
  51.     if not turtle.detect() then
  52.         turtle.place()
  53.     end
  54. end
  55.  
  56. function shaftleft()
  57.     block()
  58.     turtle.up()
  59.     if not turtle.detectUp() then
  60.         turtle.placeUp()
  61.     end
  62.     turtle.turnLeft()
  63.     placeblockforward()
  64.     turtle.down()
  65.     placeblockforward()
  66.     turtle.down()
  67.     placeblockforward()
  68.     turtle.turnRight()
  69.     if not turtle.detectDown() then
  70.         turtle.placeDown()
  71.     end
  72.     turtle.up()
  73. end
  74.  
  75. function shaftmiddle()
  76.     block()
  77.     turtle.up()
  78.     if not turtle.detectUp() then
  79.         turtle.placeUp()
  80.     end
  81.     turtle.down()
  82.     turtle.down()
  83.     if not turtle.detectDown() then
  84.         turtle.placeDown()
  85.     end
  86.     turtle.up()
  87. end
  88.  
  89. function shaftright()
  90.     block()
  91.     turtle.up()
  92.     if not turtle.detectUp() then
  93.         turtle.placeUp()
  94.     end
  95.     turtle.turnRight()
  96.     placeblockforward()
  97.     turtle.down()
  98.     placeblockforward()
  99.     turtle.down()
  100.     placeblockforward()
  101.     turtle.turnLeft()
  102.     if not turtle.detectDown() then
  103.         turtle.placeDown()
  104.     end
  105.     turtle.up()
  106. end
  107.  
  108. --Opening Instructions
  109. print("Welcome to the 3x3 Branch Mine Corridor v1.0!")
  110. sleep(1)
  111. print("Before we begin, make sure your turtle is positioned one block off of the floor of the corridor, on the right side, one block into the corridor.")
  112. sleep(1)
  113. print("Are you sure the turtle is positioned correctly?")
  114. sleep(1)
  115. print("Press any key to continue...")
  116. os.pullEvent("char")
  117.  
  118. --Defining Length
  119. term.clear()
  120. term.setCursorPos(1,1)
  121. term.write("How long should the corridor be? ")
  122. distance = read()
  123.  
  124. --Making the Right Corridor
  125. n = 0
  126. for i = 2, distance do
  127.     fuel()
  128.     dig()
  129.     shaftright()
  130.     n = n + 1
  131.     if n == 4 then
  132.         torch()
  133.         n = 0
  134.     end
  135. end
  136.  
  137. --Right to Middle Transition
  138. turtle.turnLeft()
  139. dig()
  140. turtle.turnRight()
  141. block()
  142. turtle.up()
  143. if not turtle.detectUp() then
  144.     turtle.placeUp()
  145. end
  146. placeblockforward()
  147. turtle.down()
  148. placeblockforward()
  149. turtle.down()
  150. placeblockforward()
  151. turtle.turnLeft()
  152. turtle.turnLeft()
  153. if not turtle.detectDown() then
  154.     turtle.placeDown()
  155. end
  156. turtle.up()
  157.  
  158. --Making the Middle Corridor
  159. for i = 2, distance do
  160.     fuel()
  161.     dig()
  162.     shaftmiddle()
  163. end
  164.  
  165. --Middle to Left Transition
  166. turtle.turnRight()
  167. dig()
  168. turtle.up()
  169. block()
  170. if not turtle.detectUp() then
  171.     turtle.placeUp()
  172. end
  173. placeblockforward()
  174. turtle.down()
  175. placeblockforward()
  176. turtle.down()
  177. placeblockforward()
  178. turtle.turnRight()
  179. if not turtle.detectDown() then
  180.     turtle.placeDown()
  181. end
  182. turtle.up()
  183.  
  184. --Making the Left Corridor
  185. n = 0
  186. for i = 2, distance do
  187.     fuel()
  188.     dig()
  189.     shaftright()
  190.     n = n + 1
  191.     if n == 4 then
  192.         torch()
  193.         n = 0
  194.     end
  195. end
  196.  
  197. --Returning Home
  198. turtle.turnRight()
  199. turtle.forward()
  200. turtle.turnRight()
  201. turtle.down()
  202. for i = 1, distance do
  203.     fuel()
  204.     turtle.forward()
  205. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement