Spiker985

FTB - Tunnelbore

Nov 16th, 2013
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.24 KB | None | 0 0
  1. local tArgs = {...}
  2. local supply = peripheral.wrap("right") --Resupply Station
  3.  
  4. function startup()
  5.     term.clear()
  6.     term.setCursorPos(1,1)
  7.     print("Beginning tunnel")
  8.     turtle.select(1)
  9.     supply.link()
  10.     turtle.forward()
  11. end
  12.  
  13. function checkArgs()
  14.     if #tArgs >= 3 or #tArgs == 0 then
  15.         print("Invalid parameters, must contain at least 2 parameters <Distance, Direction>")
  16.     end
  17. end
  18.  
  19. function checkSupply()
  20.     while turtle.getItemCount(15) <= 2 do
  21.         --for i = 1,60 do
  22.             --term.clear()
  23.             --term.setCursorPos(1,1)
  24.             --print("Waiting 60 seconds for more pipes")
  25.             --print("Time remaining: " .. 60 - i .. " seconds")
  26.             --sleep(1)
  27.        --end
  28.     supply.resupply(15)
  29.     end
  30. end
  31.  
  32. function send()
  33.     turtle.select(16) --MFR Item Collector
  34.     turtle.place()
  35.     turtle.up()
  36.     for i = 1,14 do
  37.         turtle.select(i)
  38.         turtle.drop()
  39.     end
  40.     turtle.down()
  41.     turtle.select(16)
  42.     turtle.dig()
  43.     turtle.select(15) --Any Pipe
  44.     turtle.place()
  45.     turtle.turnLeft()
  46.     turtle.turnLeft()
  47. end
  48.  
  49. function tunnel(dist, direction)
  50.     if direction == "left" then
  51.         turtle.turnLeft()
  52.     end
  53.  
  54.     if direction == "right" then
  55.         turtle.turnRight()
  56.     end
  57.  
  58.     if direction == "back" then
  59.         turtle.turnRight()
  60.         turtle.turnRight()
  61.     end
  62.     for i = 1, tonumber(dist) do
  63.         turtle.select(1)
  64.         turtle.dig()
  65.         turtle.forward()
  66.         turtle.digUp()
  67.         turtle.turnLeft()
  68.         turtle.dig()
  69.         turtle.forward()
  70.         turtle.digUp()
  71.         turtle.back()
  72.         turtle.turnRight()
  73.         turtle.turnRight()
  74.         turtle.dig()
  75.         turtle.forward()
  76.         turtle.digUp()
  77.         turtle.back()
  78.         turtle.turnRight()
  79.         checkSupply()
  80.         send()
  81.     end
  82.     print("Tunnelling Complete")
  83.     print("Returning")
  84.     comeback(tArgs[1])
  85. end
  86.  
  87. function comeback(dist)
  88.     sleep(0) --Change this depending on your pipe type and distance, ie Gold = 0
  89.     turtle.turnLeft()
  90.     turtle.turnLeft()
  91.     for i = 1,tonumber(dist) do
  92.     turtle.dig()
  93.     turtle.forward()
  94.     end
  95. end
  96.  
  97. startup()
  98. checkArgs()
  99. checkSupply()
  100. tunnel(tArgs[1], tostring(tArgs[2]))
Advertisement
Add Comment
Please, Sign In to add comment