Advertisement
Niseg

advanced room builder

Mar 2nd, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. print("load building material in all slots")
  2. print(" place turtle at bottom right corner (builds in place)")
  3. print("first wall?")
  4. local x=tonumber(read())
  5. print("second wall?")
  6. local y=tonumber(read())
  7. print("height?")
  8. local z=tonumber(read())
  9. local count=0
  10. local slot =1
  11.  
  12. function ensureSlot()
  13. if count==0 then
  14. slot=slot+1;
  15. count=turtle.getItemCount(slot)
  16. if count==0 then exit() end
  17. turtle.select(slot)
  18. end
  19. end
  20.  
  21. count=turtle.getItemCount(slot)
  22. turtle.turnRight();turtle.turnRight();
  23. local zr=0;
  24. z=z-1
  25. zr=z %3
  26. z=math.floor(z/3)
  27. if (zr~=0) then z=z+1 end
  28. local buildUp=true;
  29. local buildForward=true;
  30. for k=1,z do
  31. if(k<z) then buildUp=true;buildForward=true;
  32. elseif zr==1 then buildUp=false;buildForward=false;
  33. elseif zr==2 then buildUp=false;buildForward=true;
  34. else buildUp=true ;buildForward=true;
  35. end
  36.  
  37.  
  38. turtle.up()
  39.  
  40. for j=1,2 do
  41. for i=1,x-2 do
  42. turtle.placeDown()
  43. count=count-1;ensureSlot()
  44. if buildUp then
  45. turtle.placeUp()
  46. count=count-1;ensureSlot()
  47. end
  48. turtle.back()
  49. if buildForward then
  50. turtle.place()
  51. count=count-1;ensureSlot()
  52. end
  53. end
  54. turtle.placeDown()
  55. count=count-1;ensureSlot()
  56. if buildUp then
  57. turtle.placeUp()
  58. count=count-1;ensureSlot()
  59. end
  60. turtle.turnLeft()
  61. turtle.back()
  62. if buildForward then
  63. turtle.place()
  64. count=count-1;ensureSlot()
  65. end
  66.  
  67. for i=1,y-2 do
  68. turtle.placeDown()
  69. count=count-1;ensureSlot()
  70. if buildUp then
  71. turtle.placeUp()
  72. count=count-1;ensureSlot()
  73. end
  74. turtle.back()
  75. if buildForward then
  76. turtle.place()
  77. count=count-1;ensureSlot()
  78. end
  79. end
  80. turtle.placeDown()
  81. count=count-1;ensureSlot()
  82. if buildForward and j==2 then
  83. turtle.up()
  84. turtle.placeDown()
  85. count=count-1;ensureSlot()
  86. end
  87. if buildUp then
  88. if j==1 then
  89. turtle.placeUp()
  90. count=count-1;ensureSlot()
  91. else
  92. turtle.up()
  93. turtle.placeDown()
  94. count=count-1;ensureSlot()
  95. end
  96. end
  97.  
  98. turtle.turnLeft()
  99. turtle.back()
  100. if buildForward and j==1 then
  101. turtle.place()
  102. count=count-1;ensureSlot()
  103. end
  104.  
  105. end
  106. end
  107.  
  108. turtle.forward()
  109. turtle.up()
  110. for j=1,y do
  111. for i=1,x-1 do
  112.  
  113. turtle.placeDown()
  114. count=count-1;ensureSlot()
  115. turtle.back()
  116. end
  117. turtle.placeDown()
  118. count=count-1;ensureSlot()
  119. if(j%2== 1) then turtle.turnLeft() else turtle.turnRight() end
  120. turtle.back()
  121.  
  122. if(j%2== 1) then turtle.turnLeft() else turtle.turnRight() end
  123. --turtle.back()
  124.  
  125. end
  126. if(zr~=0) then z=z-1; end
  127. z=z*3+zr
  128. for i=1,z do turtle.down() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement