Advertisement
towwey

quarrysetup

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