Advertisement
Tomlacko

ComputerCraft Quarry perimeter (middle)

May 8th, 2016
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.41 KB | None | 0 0
  1. function go(dir)
  2.   if dir=="fwd" then
  3.     while turtle.forward() == false do
  4.       turtle.dig()
  5.       turtle.attack()
  6.     end
  7.   elseif dir=="up" then
  8.     while turtle.up() == false do
  9.       turtle.digUp()
  10.       turtle.attackUp()
  11.     end
  12.   elseif dir=="down" then
  13.     while turtle.down() == false do
  14.       turtle.digDown()
  15.       turtle.attackDown()
  16.     end
  17.   elseif dir=="back" then
  18.     while turtle.back() == false do
  19.       turtle.turnLeft()
  20.       turtle.turnLeft()
  21.       turtle.dig()
  22.       turtle.attack()
  23.       turtle.turnLeft()
  24.       turtle.turnLeft()
  25.     end
  26.   end
  27. end
  28.  
  29. function refuel()
  30.   print("Fuel needed: " .. 8*size + 10)
  31.   print(" ")
  32.   turtle.select(16)
  33.   while turtle.getFuelLevel() < (8*size + 10) do
  34.     if turtle.refuel(1) == false then
  35.       sleep(0.5)
  36.     end
  37.   end
  38. end
  39.  
  40. function items()
  41.   turtle.select(1)
  42.   if turtle.getItemCount(1) < 12 then
  43.     print("Place 12 blocks in the first slot.")
  44.     while turtle.getItemCount(1) < 12 do
  45.       sleep(1)
  46.     end
  47.   end
  48. end
  49.  
  50. function node()
  51.   turtle.digDown()
  52.   turtle.placeDown()
  53.   mark = mark+1
  54.   print(mark .. "/12")
  55. end
  56.  
  57. function line()
  58.   for i=1, size do
  59.     turtle.digUp()
  60.     turtle.dig()
  61.     go(fwd)
  62.   end
  63.   turtle.digUp()
  64. end
  65.  
  66. function edgeUp()
  67.   turtle.turnLeft()
  68.   go(up)
  69.   turtle.digUp()
  70.   go(up)
  71.   turtle.digUp()
  72.   turtle.dig()
  73.   go(fwd)
  74.   turtle.digUp()
  75.   turtle.dig()
  76.   go(fwd)
  77.   turtle.digUp()
  78.   turtle.turnLeft()
  79. end
  80.  
  81. function edge()
  82.   turtle.turnLeft()
  83.   turtle.dig()
  84.   go(fwd)
  85.   turtle.digUp()
  86.   turtle.turnLeft()
  87. end
  88.  
  89. function edgeDown()
  90.   turtle.turnLeft()
  91.   turtle.dig()
  92.   go(fwd)
  93.   turtle.digUp()
  94.   turtle.dig()
  95.   go(fwd)
  96.   turtle.digUp()
  97.   turtle.digDown()
  98.   go(down)
  99.   turtle.digDown()
  100.   go(down)
  101.   turtle.turnLeft()
  102. end
  103.  
  104. -------------------------------------------------------
  105.  
  106. up = "up"
  107. down = "down"
  108. back = "back"
  109. fwd = "fwd"
  110. mark = 0
  111.  
  112. write("Quarry size: ")
  113. size = read() + -1
  114. while size < 2 or size > 63 do
  115.   print("Invalid size! (Min = 3, Max = 64)")
  116.   size = read() + -1
  117. end
  118.  
  119. refuel()
  120. items()
  121.  
  122. --------------------------------------------------------
  123.  
  124. turtle.turnRight()
  125. node()
  126.  
  127. line()
  128. node()
  129. edgeUp()
  130. node()
  131.  
  132. line()
  133. node()
  134. turtle.turnRight()
  135.  
  136. line()
  137. node()
  138. edge()
  139. node()
  140.  
  141. line()
  142. node()
  143. turtle.turnRight()
  144.  
  145. line()
  146. node()
  147. edgeDown()
  148. node()
  149.  
  150. line()
  151. node()
  152. turtle.turnRight()
  153.  
  154. line()
  155. node()
  156. edge()
  157. node()
  158.  
  159. line()
  160.  
  161. print("done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement