Griffork

Fancy Tower v1.3

Aug 29th, 2012
70
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]) < 5 or tonumber(args[i]) > 9 then
  15.         shell.run("clear")
  16.         print("Invalid arguments")
  17.         print("All measurements must be numbers greater than 5 and less than 9")
  18.         do return end
  19.     end
  20. end
  21. --------------------------------------------------
  22.  
  23. --commandline arguments [height]
  24. length = tonumber(args[1])  --length of square
  25.  
  26. --The position of each of the blocks of interest
  27. -- these blocks are used for different parts of the tower.
  28. wallslot = 1
  29. floorslot = 4
  30. roofslot = 5
  31. torchslot = 6
  32. ladderslot = 7
  33. glassslot = 8
  34. roofslot = 9
  35.  
  36. function checkSlots()
  37.     if turtle.getItemCount(wallslot) < 1 then
  38.         slotnum = wallslot + 1
  39.         turtle.select(wallslot)
  40.     end
  41.     return
  42. end
  43. --------------------------------------------------
  44.  
  45. --Finish location (at H)
  46. -- [ ][w][w][w][ ]
  47. -- [w][ ][ ][ ][w]
  48. -- [d][ ][ ][ ][w]
  49. -- [H][ ][ ][ ][w]
  50. -- [ ][w][w][w][ ]
  51. -- This is where the bot should be after each function
  52. -- (top down view) facing up
  53.  
  54.  
  55.  
  56. -- Create the walls of the tower.
  57. function walls (height)
  58.     for i = 1, height do
  59.         if not turtle.detectUp() then
  60.             turtle.up()
  61.         end
  62.         for j = 1, 4 do
  63.             for k = 1, 3 do
  64.                 if not turtle.detectDown() then
  65.                     checkSlots()
  66.                     turtle.placeDown()
  67.                 end
  68.                 turtle.forward()
  69.             end
  70.             turtle.turnRight()
  71.             turtle.forward()
  72.         end
  73.     end
  74. end
  75.  
  76. -- Door and windows.
  77. function openings(height)
  78.     --get back to floor level
  79.     turtle.forward()
  80.     turtle.turnLeft()
  81.     turtle.back()
  82.     for i = 1, length do
  83.         turtle.down()
  84.     end
  85.    
  86.     currentHeight = 1
  87.    
  88.     turtle.dig()
  89.     turtle.up()
  90.     turtle.dig()
  91.     currentHeight = currentHeight + 1
  92.    
  93.     while currentHeight < height - 3 do
  94.         for i = 1, 4 do
  95.             if i == 4 and currentHeight == 2 then
  96.             end
  97.             else then
  98.             turtle.back()
  99.             turtle.turnRight()
  100.             turtle.forward()
  101.             turtle.dig()
  102.             turtle.up()
  103.             turtle.dig()
  104.             turtle.down()
  105.             end
  106.         end
  107.         turtle.up()
  108.         turtle.up()
  109.         turtle.up()
  110.         turtle.up()
  111.         currentHeight = currentHeight + 4
  112.     end
  113. end
  114.  
  115. -- turtle.turnRight()
  116. -- turtle.turnRight()
  117. -- turtle.dig()
  118. -- turtle.up()
  119. -- turtle.dig()
  120. -- turtle.down()
  121. -- turtle.turnRight()
  122. -- turtle.forward()
  123. -- turtle.turnRight()
  124. -- for i = 1, length do
  125.     -- turtle.forward()
  126.     -- if turtle.getItemCount(slotnum) < 1 then
  127.         -- slotnum = slotnum + 1
  128.         -- turtle.select(slotnum)
  129.     -- end
  130.     -- turtle.placeDown()
  131.     -- turtle.up()
  132.     -- turtle.forward()
  133.     -- if turtle.getItemCount(slotnum) < 1 then
  134.         -- slotnum = slotnum + 1
  135.         -- turtle.select(slotnum)
  136.     -- end
  137.     -- turtle.placeDown()
  138.     -- turtle.turnRight()
  139. -- end
Advertisement
Add Comment
Please, Sign In to add comment