Advertisement
ladyDia

skyscapercode

Dec 22nd, 2020 (edited)
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. local a = {}
  2. local args = {...}
  3.  
  4. local floors = tonumber(args[1])
  5. local windowSize = tonumber(args[2])
  6. local windowNumber = tonumber(args[3])
  7. local windowHeight = tonumber(args[4])+1
  8. local layer = 0
  9. local layerCount = 0
  10. local floorCount = 0
  11. local inventorySlot = 1
  12. local backForth = 0
  13. local placeDist = 0
  14.  
  15. local xPos = 0
  16. local yPos = 0
  17. local zPos = 0
  18. local rotation = 0
  19.  
  20. local xTemp = 0
  21. local yTemp = 0
  22. local zTemp = 0
  23. local rotTemp = 0
  24.  
  25. local xDiff = 0
  26. local yDiff = 0
  27. local zDiff = 0
  28. local rotDiff = 0
  29.  
  30. function a.goToPlace(x,y,z,rot)
  31. xDiff = xPos-x
  32. yDiff = yPos-y
  33. zDiff = zPos-z
  34. rotDiff = rotation - rot
  35.  
  36. while(rotDiff ~= 0)
  37. do
  38. if(rotDiff>0)
  39. then
  40. turtle.turnLeft()
  41. rotDiff = rotDiff -90
  42. rotation = rotation - 90
  43. end
  44. if(rotDiff<0)
  45. then
  46. turtle.turnRight()
  47. rotDiff = rotDiff + 90
  48. rotation = rotation+90
  49. end
  50. end
  51. if xDiff ~=0 then
  52. turtle.turnRight()
  53. while xDiff ~= 0 do
  54. if xDiff<0 then
  55. turtle.back()
  56. xDiff = xDiff+1
  57. xPos = xPos+1
  58. end
  59. if xDiff > 0 then
  60. turtle.forward()
  61. xDiff = xDiff-1
  62. xPos = xPos-1
  63. end
  64. end
  65. turtle.turnLeft()
  66. end
  67. while(zDiff~=0)
  68. do
  69. if(zDiff>0)
  70. then
  71. turtle.back()
  72. zDiff = zDiff - 1
  73. zPos = zPos -1
  74. end
  75. if(zDiff<0)
  76. then
  77. turtle.forward()
  78. zDiff = zDiff+1
  79. zPos = zPos+1
  80. end
  81. end
  82. while(yDiff~=0)
  83. do
  84. if(yDiff>0)
  85. then
  86. turtle.down()
  87. yDiff = yDiff -1
  88. yPos = yPos -1
  89. end
  90. if(yDiff<0)
  91. then
  92. turtle.up()
  93. yDiff = yDiff+1
  94. yPos = yPos+1
  95. end
  96. end
  97. end
  98.  
  99. function a.wallPlacement()
  100. if(turtle.getItemCount(inventorySlot)<1)
  101. then
  102. if(inventorySlot==16)
  103. then
  104. inventorySlot = 1
  105. turtle.select(inventorySlot)
  106. xTemp = xPos
  107. yTemp = yPos
  108. zTemp = zPos
  109. rotTemp = rotation
  110. a.goToPlace(0,0,-1,0)
  111. print("Please give me material")
  112. while(turtle.getItemCount(inventorySlot)<1)
  113. do
  114. sleep(10)
  115. end
  116. print("Thank you!")
  117. a.goToPlace(0,yTemp,-1,0)
  118. a.goToPlace(xTemp,yTemp,zTemp,rotTemp)
  119. else
  120. inventorySlot = inventorySlot+1
  121. turtle.select(inventorySlot)
  122. end
  123. end
  124. if(layer==0)
  125. then
  126. turtle.placeDown()
  127. end
  128. if layer>0 and layer<windowHeight+2
  129. then
  130. if(xPos==((windowSize+1)*windowNumber+1))or(zPos==((windowSize+1)*windowNumber))or(xPos==0)or(zPos==0)
  131. then
  132. if layer>1 and layer<windowHeight+1
  133. then
  134. if(xPos%(windowSize+1)==0) and (zPos%(windowSize+1)==0)
  135. then
  136. print("WindowPlace")
  137. turtle.placeDown()
  138. end
  139. end
  140. if layer == 1 or layer == (windowHeight+1)
  141. then
  142. turtle.placeDown()
  143. end
  144. end
  145. end
  146. if(layer==windowHeight+2)
  147. then
  148. layer = 0
  149. end
  150. end
  151.  
  152. function a.checkFuel()
  153. if(turtle.getFuelLevel()<(xPos+yPos+zPos+20))
  154. then
  155. inventorySlot = 1
  156. turtle.select(inventorySlot)
  157. xTemp = xPos
  158. yTemp = yPos
  159. zTemp = zPos
  160. rotTemp = rotation
  161. a.goToPlace(0,0,-1,0)
  162. print("Please give me fuel")
  163. while(turtle.getFuelLevel()<20)
  164. do
  165. turtle.refuel()
  166. end
  167. print("Thank you!")
  168. a.goToPlace(0,yTemp,-1,0)
  169. a.goToPlace(xTemp,yTemp,zTemp,rotTemp)
  170. end
  171. end
  172.  
  173. turtle.forward()
  174. turtle.forward()
  175. while(layerCount<floors*(windowHeight+3))
  176. do
  177. for x = 0, (windowSize+1)*windowNumber do
  178. for z = 0,(windowSize+1)*windowNumber do
  179. a.wallPlacement()
  180. if(backForth%2==0)then a.goToPlace(x,yPos,z,0) end
  181. if(backForth%2==1)then a.goToPlace(x,yPos,(((windowSize+1)*windowNumber)-z),0) end
  182. a.checkFuel()
  183. end
  184. backForth = backForth + 1
  185. end
  186. backForth = 0
  187. print("UP WE GO")
  188. a.goToPlace(0,yPos+1,0,0)
  189. layer = layer +1
  190. layerCount = layerCount + 1
  191. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement