Griffork

Tower With Stairs v2

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