spankyTheBeaver

Untitled

Aug 29th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.56 KB | None | 0 0
  1. --enderchests:
  2.  
  3. --white = 0, red = 1
  4.  
  5. --241 0 wall slot 14
  6. --241:224 2 roof slot 15
  7. --241:14 1 fuel slot 16
  8. --
  9.  
  10. local action = "wall"
  11. local roofType = 0
  12.  
  13. local materialSlot = 1
  14. local materialChestSlot = 14
  15.  
  16. local roofSlot = 12
  17. local roofChestSlot = 15
  18.  
  19. local FuelSlot = 13
  20. local FuelChestSlot = 16
  21.  
  22. local xt = 0
  23. local yt = 0
  24.  
  25. local xcalc = 0 --voor berekening
  26. local ycalc = 0
  27. local angle = 1
  28. --local angleIncrease = 1 --resolutie circel
  29.  
  30. local ht = 0
  31. local hhl = 1
  32. local diam = 10 --voor dak zonder toren
  33.  
  34. local autostart = 0 --voor autodinges
  35.  
  36.  
  37. function selMat()
  38.  
  39. local fillSlot = 1
  40.  
  41. while turtle.getItemCount(materialSlot) == 0 do
  42. materialSlot = materialSlot + 1
  43. if materialSlot == 12 then
  44. turtle.select(materialChestSlot)
  45. turtle.placeUp()
  46. while fillSlot < 12 do
  47. turtle.select(fillSlot)
  48. turtle.suckUp(fillSlot)
  49. fillSlot = fillSlot + 1
  50. end
  51. turtle.select(materialChestSlot)
  52. turtle.digUp()
  53. materialSlot = 1
  54. else
  55. end
  56. end
  57. turtle.select(materialSlot)
  58. end
  59.  
  60. function selRoofMat()
  61. if turtle.getItemCount(roofSlot) == 0 then
  62. turtle.select(roofChestSlot)
  63. turtle.placeUp()
  64. turtle.select(roofSlot)
  65. turtle.suckUp(roofSlot)
  66. turtle.select(roofChestSlot)
  67. turtle.digUp()
  68. else
  69. end
  70. turtle.select(roofSlot)
  71. end
  72.  
  73. function getTowerWallSpec()
  74.  
  75. local aftreksel = 0
  76.  
  77. term.clear()
  78. term.setCursorPos(1,1)
  79. term.write(" tower diameter = ")
  80. diam = tonumber(read())
  81. term.write(" tower height = ")
  82. hhl = tonumber(read())
  83. term.write("this is the center [y/n] ")
  84. center = tostring(read())
  85. print(" ")
  86.  
  87. origineleDiam = diam
  88.  
  89. while diam < 17 and aftreksel == 0 do
  90. term.clear()
  91. term.setCursorPos(1,1)
  92. print("Circels smaller than 17 look like crap.")
  93. print(" Are you sure you want to continue? ")
  94. print(" ")
  95. term.write(" y/n ")
  96. queef = tostring(read())
  97. print(" ")
  98. if queef ~= "y" and queef ~= "Y" then
  99. getTowerWallSpec()
  100. else
  101. aftreksel = 1
  102. end
  103. end
  104. end
  105.  
  106. function getRoofSpec()
  107. term.clear()
  108. term.setCursorPos(1,1)
  109. print("Roof properties:")
  110. print(" ")
  111. print("0-No roof")
  112. print("1-Pointy Roof")
  113. print("2-Slanted Roof")
  114. print(" ")
  115. term.write("Choose type = ")
  116. roofType = tonumber(read())
  117. print(" ")
  118.  
  119. if roofType == 1 then
  120. term.clear()
  121. term.setCursorPos(1,1)
  122. print("Roof properties:")
  123. print(" ")
  124. term.write("Roof overhang = ")
  125. overhang = tonumber(read())
  126. print(" ")
  127. roofOffset = overhang + 1
  128. elseif roofType == 2 then
  129. print("Slanted")
  130. else
  131. end
  132.  
  133. end
  134.  
  135. function toCenter()
  136. local ft = 0
  137. if center == "y" or center == "Y" then
  138. turtle.turnRight()
  139. while ft < diam/2 do
  140. turtle.forward()
  141. ft = ft + 1
  142. print(ft.."/"..diam/2)
  143. end
  144. turtle.turnLeft()
  145. else
  146. end
  147. end
  148.  
  149. function round(num, idp)
  150. local mult = 10^(idp or 0)
  151. return math.floor(num * mult + 0.5) / mult
  152. end
  153.  
  154. function drawCircel()
  155.  
  156. for angle = 1, 360 do
  157. xcalc = math.cos(angle * math.pi / 180) * diam + xcalc
  158. ycalc = math.sin(angle * math.pi / 180) * diam + ycalc
  159. xCoordinate = round(xcalc/110, 0)
  160. yCoordinate = round(ycalc/110, 0)
  161. moveToXY()
  162. angle = angle + 1
  163. printPos(angle, ht)
  164. reFuel()
  165. if action == "wall" then
  166. selMat()
  167. elseif action == "roof" then
  168. selRoofMat()
  169. else
  170. print("fuckass")
  171. sleep(20)
  172. end
  173. turtle.placeDown()
  174. --sleep(0.1)
  175. end
  176. end
  177.  
  178. function moveToXY()
  179.  
  180. while xt > xCoordinate do
  181. local moved = false
  182. while not moved do
  183. moved = turtle.forward()
  184. end
  185. xt = xt - 1
  186. end
  187.  
  188. while xt < xCoordinate do
  189. moved = false
  190. while not moved do
  191. moved = turtle.back()
  192. end
  193. xt = xt + 1
  194. end
  195.  
  196. while yt > yCoordinate do
  197. turtle.turnRight()
  198. moved = false
  199. while not moved do
  200. moved = turtle.forward()
  201. end
  202. turtle.turnLeft()
  203. yt = yt - 1
  204. end
  205.  
  206. while yt < yCoordinate do
  207. turtle.turnRight()
  208. moved = false
  209. while not moved do
  210. moved = turtle.back()
  211. end
  212. turtle.turnLeft()
  213. yt = yt + 1
  214. end
  215.  
  216. end
  217.  
  218. function printPos(angle, ht)
  219.  
  220. progress = 100 * (angle / 360 + ht) / hhl
  221. progressR = round(progress, 1)
  222. roofProgress = 100 * (angle / 360)
  223. roofProgressR = round(roofProgress, 1)
  224. roofLevel = ht - hhl
  225. if roofOffset > 0 then
  226. maxRoofLevel = (origineleDiam + 2) / 2
  227. else
  228. maxRoofLevel = (origineleDiam - 2) / 2
  229. end
  230. term.clear()
  231. term.setCursorPos(1,1)
  232. print("diameter = "..diam.." blocks")
  233. print("angle = "..angle.." deg")
  234. print(" ")
  235. if action == "wall" then
  236. print("Wall:")
  237. print(" ")
  238. print("Wall height = "..ht.."/"..hhl)
  239. print("Wall progress = "..progressR.."%")
  240. elseif action == "roof" then
  241. print("Roof:")
  242. print(" ")
  243. print("Overhang = "..overhang)
  244. print("Roof height = "..roofLevel.."/"..maxRoofLevel)
  245. print("Current level progress = "..roofProgressR.."%")
  246. else
  247. end
  248.  
  249.  
  250. end
  251.  
  252. function reFuel()
  253. if turtle.getFuelLevel() < 10 then
  254. if turtle.getItemCount(FuelSlot) == 0 then
  255. turtle.select(FuelChestSlot)
  256. turtle.placeUp()
  257. turtle.select(FuelSlot)
  258. turtle.suckUp()
  259. turtle.select(FuelChestSlot)
  260. turtle.digUp()
  261. else
  262. end
  263. turtle.select(FuelSlot)
  264. turtle.refuel()
  265. else
  266. end
  267. end
  268.  
  269. function towerWall()
  270.  
  271. action = "wall"
  272.  
  273. toCenter()
  274.  
  275. while ht < hhl do
  276. drawCircel()
  277. local moved = false
  278. while not moved do
  279. moved = turtle.up()
  280. end
  281. ht = ht + 1
  282. reFuel()
  283. end
  284.  
  285. end
  286.  
  287. function towerRoof()
  288. local ot = 1
  289. action = "roof"
  290. diam = diam + 2 * roofOffset
  291. if roofOffset > 0 then
  292. turtle.turnRight()
  293. while ot < roofOffset do
  294. local moved = false
  295. while not moved do
  296. moved = turtle.forward()
  297. end
  298. ot = ot + 1
  299. end
  300. turtle.turnLeft()
  301. elseif roofOffset <= 0 then
  302. turtle.turnLeft()
  303. while ot > roofOffset do
  304. moved = false
  305. while not moved do
  306. moved = turtle.forward()
  307. end
  308. ot = ot - 1
  309. end
  310. turtle.turnRight()
  311. else
  312. print("kloothommel")
  313. end
  314.  
  315. while diam > 1 do
  316. diam = diam - 2
  317. drawCircel()
  318. turtle.up()
  319. ht = ht + 1
  320. progress = 0
  321. turtle.turnLeft()
  322. moved = false
  323. while not moved do
  324. moved = turtle.forward()
  325. end
  326. turtle.turnRight()
  327. end
  328.  
  329. end
  330.  
  331. function slantedTowerRoof()
  332. action = "roof"
  333. while diam > 1 do
  334. diam = diam - 1
  335. drawCircel()
  336. local moved = false
  337. while not moved do
  338. moved = turtle.up()
  339. end
  340. ht = ht + 1
  341. progress = 0
  342. end
  343.  
  344. end
  345.  
  346. function tower()
  347.  
  348. reFuel()
  349.  
  350. getTowerWallSpec()
  351.  
  352. getRoofSpec()
  353.  
  354. towerWall()
  355.  
  356. if roofType == 1 then
  357. towerRoof()
  358. elseif roofType == 2 then
  359. slantedTowerRoof()
  360. else
  361. end
  362.  
  363. end
  364.  
  365. --[[
  366. so for arguments: diameter height overhang autostart
  367. example: tower 20 40 2 1
  368. --]]
  369.  
  370. local args = { ... }
  371. if args[1] == nil then
  372. tower()
  373. else
  374. diam = tonumber(args[1]) --diameter
  375. hhl = tonumber(args[2]) --tower height
  376. overhang = tonumber(args[3]) --should be 2
  377. if args[4] == nil then
  378. autostart = 0
  379. else
  380. autostart = tonumber(args[4])
  381. end
  382.  
  383. roofOffset = overhang + 1
  384. local center = "y"
  385. origineleDiam = diam
  386.  
  387. if autostart == 1 then --refuel en alle kistjes pakken
  388. turtle.select(FuelSlot)
  389. turtle.suckDown(16)
  390. turtle.refuel()
  391. turtle.select(FuelChestSlot)
  392. turtle.digDown()
  393. turtle.down()
  394. turtle.select(materialChestSlot)
  395. turtle.digDown()
  396. turtle.down()
  397. turtle.select(roofChestSlot)
  398. turtle.digDown()
  399. turtle.down()
  400. local moved = false
  401. local dist = 0
  402. while dist < 5 do
  403. while not moved do
  404. moved = turtle.up()
  405. end
  406. dist = dist + 1
  407. end
  408. else
  409. end
  410. reFuel()
  411. towerWall()
  412. towerRoof()
  413. print("done")
  414. end
Add Comment
Please, Sign In to add comment