Advertisement
Vorakh

computercraft turtle piazza torce

Apr 25th, 2021 (edited)
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. local tArgs = { ... }
  2. if #tArgs ~= 1 then
  3.     print( "Usage: tunnel_3x3 <length>" )
  4.     return
  5. end
  6.  
  7. -- Mine in a quarry pattern until we hit something we can't dig
  8. local length = tonumber( tArgs[1] )
  9. if length < 1 then
  10.     print( "Tunnel length must be positive" )
  11.     return
  12. end
  13. if length < 8 then
  14.     print("Tunnel length must be > 8")
  15.     return
  16. end
  17.  
  18. local function tryPlaceDown()
  19.     turtle.select(16)
  20.     turtle.placeDown()
  21. end
  22. --[[ ]]
  23. local sub_length = length
  24. local ritorno = 0
  25. turtle.up()
  26. tryPlaceDown()
  27. for n=1, sub_length do
  28.    
  29.     for i=1, 8 do
  30.         turtle.forward()
  31.         sub_length = sub_length - 1
  32.         ritorno = ritorno +1
  33.     end
  34.     tryPlaceDown()
  35.     if sub_length < 8 then
  36.         break
  37.     end
  38.        
  39. end
  40.  
  41.  
  42. --[[ ]]
  43. print( "Returning to start..." )
  44.  
  45. -- Return to where we started
  46. depth = ritorno
  47.  
  48. turtle.turnLeft()
  49. turtle.turnLeft()
  50. while depth > 0 do
  51.     if turtle.forward() then
  52.         depth = depth - 1
  53.     else
  54.         turtle.dig()
  55.     end
  56. end
  57. turtle.forward()
  58. turtle.down()
  59. turtle.turnRight()
  60. turtle.turnRight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement