mjmac85

Turtle Tunnel no torch

Mar 24th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2.     Original Author
  3.         Rasmus Sommer aka. TheSommer
  4.         youtube.com/thesommersmc
  5.         twitch.tv/thesommer
  6.     Edited by Mjmac85
  7.    
  8.     How to use:
  9.         Slot 1 - Fuel
  10.         Slot 2 - Bridge material
  11.         Slot 3 - Torches
  12.  
  13. Edit:Place chest directly behind the turtle at the start point.  
  14.    
  15.         torchedtunnel <length>
  16. --]]
  17.  
  18. local tArgs = { ... }
  19. if #tArgs ~= 1 then
  20.     print( "Usage: torchedtunnel <length>" )
  21.     return
  22. end
  23.  
  24. local length = tonumber( tArgs[1] )
  25. if length < 1 then
  26.     print( "Tunnel length must be positive" )
  27.     return
  28. end
  29.  
  30. local function tryRefuel()
  31.     if turtle.getFuelLevel() == 0 then
  32.         turtle.select(1)
  33.         turtle.refuel(1)
  34.     end
  35. end
  36.  
  37. local function tryDig()
  38.     while turtle.detect() == true do
  39.         turtle.dig()
  40.         sleep(0.5)
  41.     end
  42. end
  43.  
  44. local function tryDigUp()
  45.     while turtle.detectUp() == true do
  46.         turtle.digUp()
  47.         sleep(0.5)
  48.     end
  49. end
  50.  
  51. local function tryUp()
  52.     tryDigUp()
  53.     tryRefuel()
  54.     turtle.up()
  55. end
  56.  
  57. local function tryDown()
  58.     while turtle.detectDown() == true do
  59.         turtle.digDown()
  60.         sleep(0.5)
  61.     end
  62.     tryRefuel()
  63.     turtle.down()
  64. end
  65.  
  66. local function tryForward()
  67.     tryDig()
  68.     tryRefuel()
  69.     turtle.forward()
  70. end
  71.  
  72. local function makeBridge()
  73.     if turtle.detectDown() == false then
  74.         turtle.select(2)
  75.         turtle.placeDown()
  76.     end
  77. end
  78.  
  79. local count = 1
  80.  
  81. --Emptys inventory into a chest
  82. local function dropItems()
  83.     local invCount = 4
  84.     for invCount = 4, 16 do
  85.         turtle.select(invCount)
  86.         turtle.drop()
  87.     end
  88.     turtle.select(4)
  89. end
  90.  
  91.  
  92. --Turns the turtle around calls dropItems and goes back to mining
  93. local function returnTrip(count)
  94.     turtle.turnRight()
  95.     turtle.turnRight()
  96.     for moveCount = 1, count - 1 do
  97.         tryForward()
  98.     end
  99.     turtle.turnLeft()
  100.     dropItems()
  101.     turtle.turnLeft()
  102.  
  103.     for moveCount = 1, count - 1 do
  104.         tryForward()
  105.     end
  106. end
  107.  
  108.  
  109. for i = 1, length do
  110. --Checks item count and drops if full    
  111.     if turtle.getItemCount(16) > 0 then
  112.         returnTrip(count)
  113.     end
  114.     tryForward()
  115.     count = count + 1
  116.     makeBridge()
  117.     tryDigUp()
  118.     turtle.turnLeft()
  119.     tryDig()
  120.     tryUp()
  121.     tryDig()
  122. --Torches taken out
  123.     --if count % 8 == 0 then
  124.         --turtle.select(3)
  125.         --turtle.place()
  126.     --end
  127.     turtle.turnRight()
  128.     turtle.turnRight()
  129.     tryDig()
  130.     tryDown()
  131.     tryDig()
  132.     turtle.turnLeft()
  133. end
  134.  
  135. --Takes the turtle back to start point, drops items, and faces forward to start again
  136. turtle.turnRight()
  137. turtle.turnRight()
  138. for i = 1, count - 1 do
  139.     tryForward()
  140. end
  141. turtle.turnLeft()
  142. dropItems()
  143. turtle.turnLeft()
  144. print("Finished boss!")
Advertisement
Add Comment
Please, Sign In to add comment