towwey

quarrysetupV2

Sep 9th, 2021 (edited)
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local tArgs = { ... }
  2. if #tArgs ~= 1 then
  3.     print( "Usage: quarry size <length>" )
  4.     print( "Place blocks in slots 1 - 14, place landmarks in 16" )
  5.     return
  6. end
  7.  
  8. -- Set length with user input
  9. local length = tonumber( tArgs[1] )
  10. if length < 1 then
  11.     print( "Side length must be positive" )
  12.     return
  13. end
  14. local curSlot = 1
  15. function putblockdown()
  16.     if not (turtle.detectDown()) then
  17.         while turtle.getItemCount(curSlot) == 0 and curSlot < 16 do
  18.             curSlot = curSlot + 1
  19.         end
  20.         turtle.select(curSlot)
  21.         turtle.placeDown()
  22.     end
  23. end
  24.  
  25. -- Place Landmark in front
  26. function placelmf()
  27.     if not (turtle.detect()) then
  28.         putblockdown()
  29.         turtle.back()
  30.         turtle.select(16)
  31.         turtle.place()
  32.     end
  33. end
  34.  
  35. -- Place Landmark left and right
  36. function placelmb()
  37.     if not (turtle.detect()) then
  38.         turtle.turnRight()
  39.         turtle.forward()
  40.         putblockdown()
  41.         turtle.back()
  42.         turtle.select(16)
  43.         turtle.place()
  44.         turtle.turnLeft()
  45.         turtle.turnLeft()
  46.         turtle.forward()
  47.         putblockdown()
  48.         turtle.back()
  49.         turtle.select(16)
  50.         turtle.place()
  51.         turtle.turnRight()
  52.     end
  53. end
  54.  
  55. function backhome()
  56.     x = length
  57.     while x > 0 do
  58.     -- putblockdown()
  59.     turtle.back()
  60.     x = x - 1
  61.     end
  62. end
  63. -- Move forward <length> times
  64. local i = 0
  65. while i < length do
  66.     turtle.forward()
  67.     i = i + 1
  68. end
  69.  
  70. placelmf()
  71. backhome()
  72. turtle.turnLeft()
  73.  
  74. local i = 0
  75. while i < length do
  76.     putblockdown()
  77.     turtle.forward()
  78.     i = i + 1
  79. end
  80.  
  81. placelmb()
  82. backhome()
  83. turtle.turnLeft()
  84. turtle.forward()
  85.  
  86. local i = 0
  87. while i < length do
  88.     turtle.forward()
  89.     i = i + 1
  90. end
  91.  
  92. placelmf()
  93. backhome()
  94.  
  95. -- That's all, folks!
  96. print("Quarry setup")
  97. return
Add Comment
Please, Sign In to add comment