Griffork

Basic Tower

Aug 27th, 2012
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. print("Hello World")
  2. --TurtleTower
  3.  
  4. --Check arguments for correct formatting
  5. local args = { ... }
  6. if #args ~= 1 then      --Check if it's not exactly 3 arguments.
  7.     shell.run("clear")
  8.     print("Invalid number of arguments")
  9.     print("turtletower [height]")
  10.     do return end
  11. end
  12. for i = 1, 1 do            --Step through each argument and make sure it is a number greater than 1.
  13.     if tonumber(args[i]) < 2 then
  14.         shell.run("clear")
  15.         print("Invalid arguments")
  16.         print("All measurements must be numbers greater than 1")
  17.         do return end
  18.     end
  19. end
  20. --------------------------------------------------
  21.  
  22. --commandline arguments [height]
  23. length = tonumber(args[1])  --length of square
  24. slotnum = 1
  25. --------------------------------------------------
  26.  
  27. for i = 1, length do
  28.     if not turtle.detectUp() then
  29.         turtle.up()
  30.     end
  31.     for j = 1, 4 do
  32.         for k = 1, 3 do
  33.             if not turtle.detectDown() then
  34.                 if turtle.getItemCount(slotnum) < 3 then
  35.                     slotnum = slotnum + 1
  36.                     turtle.select(slotnum)
  37.                 end
  38.                 turtle.placeDown()
  39.             end
  40.             turtle.forward()
  41.         end
  42.         turtle.turnRight()
  43.         turtle.forward()
  44.     end
  45. end
Advertisement
Add Comment
Please, Sign In to add comment