Cwmwd24

QuarryHelp

Feb 21st, 2015
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.72 KB | None | 0 0
  1. -- -------------------------------------------------------------------------- --
  2. -- QuarryHelp : PVFXQTix
  3. --
  4. -- Turtle script to place two landmarks at 64 blocks from the starting point,
  5. -- at right angles to each other.  This is handy for setting up huge quarries.
  6. --
  7. -- -------------------------------------------------------------------------- --
  8. --
  9. -- INVENTORY:
  10. -- [1][2][3][4]
  11. -- [5][6][7][8]
  12. -- [9][A][B][C]
  13. -- [D][E][F][0]
  14. --
  15. -- 1 : Fuel (>3 coal)
  16. -- 2 : Landmark (>2)
  17. -- 3 : Filler (>2)
  18. -- 4-0 : n/a
  19. --
  20. -- -------------------------------------------------------------------------- --
  21.  
  22. local tArgs = { ... }
  23. local goLeft
  24.  
  25. local function PrintHelp()
  26.   print( "Usage:" )
  27.   print( "QuarryHelp <l|r>" )
  28.   print( "  l -- place second marker to the LEFT." )
  29.   print( "  r -- place second marker to the RIGHT." )
  30.   return
  31. end
  32.  
  33. local function CheckFuel()
  34.     if turtle.getFuelLevel() < 64 and turtle.getItemCount( 1 ) > 1 then
  35.       turtle.select( 1 )
  36.       turtle.refuel( 1 )
  37.     end
  38.     return
  39. end
  40.  
  41. -- Check the commandline
  42. if not #tArgs == 1 then
  43.   PrintHelp()
  44.   return
  45. end
  46.  
  47. if tArgs[ 1 ] == "r" then
  48.   print( "Will go RIGHT." )
  49.   goLeft = false
  50. elseif tArgs[ 1 ] == "l" then
  51.   print( "Will go LEFT." )
  52.   goLeft = true
  53. else
  54.   PrintHelp()
  55.   return
  56. end
  57.  
  58. -- Go 64 forward.
  59. for step = 1, 63 do
  60.   while turtle.detect() do
  61.     turtle.dig()
  62.   end
  63.   CheckFuel()
  64.   turtle.forward()
  65.   while turtle.detectUp() do
  66.     turtle.digUp()
  67.   end
  68. end
  69. print( "64 from start." )
  70.  
  71. -- Check for solid ground for landmark.
  72. if not turtle.detectDown() then
  73.   print( "No floor here..." )
  74.   turtle.select( 3 )
  75.   turtle.placeDown()
  76. end
  77.  
  78. -- Place marker
  79. print( "MARK." )
  80. CheckFuel()
  81. turtle.back()
  82. turtle.select( 2 )
  83. turtle.place()
  84.  
  85. -- Go back to start.
  86. print( "Going back." )
  87. for step = 2, 63 do
  88.   CheckFuel()
  89.   turtle.back()
  90. end
  91.  
  92. -- Repeat at 90o
  93. if goLeft then
  94.   print( "Starting LEFT arm" )
  95.   turtle.turnLeft()
  96. else
  97.   print( "Starting RIGHT arm" )
  98.   turtle.turnRight()
  99. end
  100.  
  101. -- Go 64 forward.
  102. for step = 1, 63 do
  103.   while turtle.detect() do
  104.     turtle.dig()
  105.   end
  106.   CheckFuel()
  107.   turtle.forward()
  108.   while turtle.detectUp() do
  109.     turtle.digUp()
  110.   end
  111. end
  112. print( "64 from start again." )
  113.  
  114. -- Check for solid ground for landmark.
  115. if not turtle.detectDown() then
  116.   print( "No floor here..." )
  117.   turtle.select( 3 )
  118.   turtle.placeDown()
  119. end
  120.  
  121. -- Place marker
  122. print( "MARK." )
  123. CheckFuel()
  124. turtle.back()
  125. turtle.select( 2 )
  126. turtle.place()
  127.  
  128. -- Go back to start.
  129. print( "Going back." )
  130. for step = 2, 63 do
  131.   CheckFuel()
  132.   turtle.back()
  133. end
  134.  
  135. print( "MARK." )
  136. turtle.up()
  137. turtle.select( 2 )
  138. turtle.placeDown()
  139. if goLeft then
  140.   turtle.turnRight()
  141. else
  142.   turtle.turnLeft()
  143. end
  144.  
  145.  
  146. -- Done.
Advertisement
Add Comment
Please, Sign In to add comment