Advertisement
downwind

Castle Wall Merlon Block Placer For Turtle in ComputerCraft

Oct 12th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | None | 0 0
  1. -- This is a block placement program for a turtle that will place a block then move 2 blocks and place another one until it reaches the given length.
  2. -- Useful for the tops of castle walls or any other situation where you need blocks spaced out.
  3.  
  4. -- Written by Richard Reigens 10/12/2013
  5. -- Version 1.3
  6.  
  7. -- Make sure turtle has building blocks and is fueled up.
  8. -- The program will detect whether there is a block under the turtle or not and start alternating the pattern based on that.
  9. -- Place your turtle facing the direction you want the line made.
  10. -- Useage is: merlon <length>
  11.  
  12.  
  13. local tArgs = {...}
  14. local length = tonumber(tArgs[1])
  15. local slot = 1
  16. local space = true
  17.  
  18. if turtle.detectDown() == true then
  19.     space = false
  20.    
  21.     end
  22.    
  23. turtle.select(slot)  
  24.  
  25. putIt = function ()
  26.     if turtle.getItemCount(slot) == 0 then
  27.       slot = slot + 1
  28.       turtle.select(slot)
  29.       turtle.placeDown()
  30.      
  31.     else
  32.       turtle.placeDown()
  33.      
  34.     end
  35. end
  36.    
  37. checkSpace = function ()
  38.     if space == true then
  39.         turtle.forward()
  40.         putIt()
  41.         space = false
  42.        
  43.     else turtle.forward()
  44.         space = true
  45.          
  46.     end
  47. end
  48.          
  49. for i = 1, length, 1 do
  50.        
  51.     if i < length then
  52.         checkSpace()
  53.    
  54.         end
  55. end
  56.  
  57. print("Complete")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement