Advertisement
masa-

CC Turtle: Simple square v0.1

Jun 6th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. local tArgs = { ... }
  2.  
  3. if #tArgs < 1 then
  4.     print("usage: name <size>")
  5.     return
  6. end
  7.  
  8. local size = tonumber( tArgs[1] )
  9.  
  10. -- Digs two sides from a square, forward and to the right
  11. function digSides(size)
  12.     -- Dig the first side ("left"), straight forward
  13.     for i = 1, size do
  14.         turtle.dig()
  15.         turtle.forward()
  16.     end
  17.  
  18.     turtle.turnRight()
  19.  
  20.     -- Dig the second side ("back") (to the right from the starting position)
  21.     for i = 1, (size - 1) do
  22.         turtle.dig()
  23.         turtle.forward()
  24.     end
  25.  
  26.     turtle.turnRight()
  27. end
  28.  
  29.  
  30. -- Dig the square, two sides at a time, reducing the size of the leftover square
  31. for i = 0, (size - 1) do
  32.     digSides(size - i)
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement