KnowThyParadox

TurtleMiner

Nov 14th, 2013
242
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. --Digs a row, as well as the row beneath it.
  2. --Length is the length of the row to dig
  3. function digRow( length, doubleRow )
  4. for i = 1, length do
  5.  
  6. -- Check if we want a Double row
  7. -- Dig out the bottom of the row we are on
  8. if ( doubleRow and turtle.detectDown() ) then
  9. turtle.digDown()
  10. end
  11.  
  12. -- If not on the last row, clear dig until we can move
  13. -- (Will move forward in the process)
  14. if ( i < length ) then
  15. while ( not turtle.forward() ) do
  16. turtle.dig()
  17. end
  18. end
  19.  
  20. end
  21. end
  22.  
  23. function digLevel( width, length, doubleRow )
  24. for i = 1, width do
  25. digRow( length, doubleRow )
  26.  
  27. -- If we're on an odd row, we want to turn right
  28. if ( i < width and i % 2 == 1 ) then
  29. turtle.turnRight()
  30. while ( not turtle.forward() ) do
  31. turtle.dig( )
  32. end
  33. turtle.turnRight( )
  34.  
  35. -- Else turn left
  36. elseif ( i < width ) then
  37. turtle.turnLeft()
  38. while ( not turtle.forward() ) do
  39. turtle.dig( )
  40. end
  41. turtle.turnLeft( )
  42. end
  43. end
  44.  
  45. -- If ending on a far side
  46. if ( i % 2 == 1 ) then
  47. turtle.turnRight()
  48. turtle.turnRight()
  49. for x = 1, length do
  50. turtle.forward()
  51. end
  52. turtle.turnRight()
  53. end
  54.  
  55. for y = 1, width do
  56. turtle.forward()
  57. end
  58.  
  59. turtle.turnRight()
  60. end
  61.  
  62. function checkInventory( )
  63.  
  64. end
  65.  
  66. local args = { ... }
  67.  
  68. -- Grab the arguments!
  69. local width = tonumber(args[ 1 ])
  70. local heigh = tonumber(args[ 2 ])
  71. local depth = tonumber(args[ 3 ])
  72.  
  73. for row = 1, depth/2 do
  74. digLevel( width, height, true )
  75.  
  76. -- Move down to the next room
  77. turtle.down()
  78. if ( turtle.detectDown() ) then
  79. turtle.digDown()
  80. end
  81. turtle.down()
  82. end
  83.  
  84. if ( depth % 2 == 1 ) then
  85. digLevel( width, height, false )
  86. end
  87.  
  88. for row = 1, depth do
  89. while ( not turtle.up() ) do
  90. turtle.digUp()
  91. end
  92. end
Advertisement
Comments
  • Comment was deleted
Add Comment
Please, Sign In to add comment