Advertisement
HarvDad

build

May 2nd, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.19 KB | None | 0 0
  1. -- build: Build predifined structures
  2. -- Rev 2.1
  3.  
  4.  
  5. args = {...}
  6. nArgs = #args
  7. version = "build: Rev 2.1"
  8. usage = "Usage: build <structure name>"
  9.  
  10. -- Locations
  11.  
  12. origin = {0, 0, 0}
  13. center = {0, 0, 15}
  14.  
  15. -- length, width, xOffset, zOffset, yOffset
  16.  
  17. base = {15, 15, 0, 0, 150}
  18. tower = {5, 5, 0, 0, 150}
  19. ladderChute = {1, 1, 0, -8, 0}
  20. drainFloor = {15, 15, 0, 0, 190}
  21. conveyors = {3, 3, 0, -1, 190}
  22. quicksand = {13, 13, 0, 0, 193}
  23. chamber = {15, 15, 0, 0, 190}
  24. roof = {15, 15, 0, 0, 198}
  25.  
  26.  
  27. -- Global Origin
  28.  
  29. gX = 0
  30. gY = 0
  31. gZ = 0
  32.  
  33. -- Base Origin
  34.  
  35. bX = 5
  36. bY = 0
  37. bZ = 5
  38.  
  39. -- Drain Origin
  40.  
  41. dX = 0
  42. dY = 0
  43. dZ = 0
  44.  
  45. -- Tower Origin
  46.  
  47. tX = 0
  48. tY = 0
  49. tZ = 0
  50.  
  51. -- Cobble Chest
  52.  
  53. ccX = 0
  54. ccY = 0
  55. ccZ = 0
  56.  
  57. -- Quicksand Chest
  58.  
  59. qcX = -2
  60. qcY = 0
  61. qcZ = 0
  62.  
  63. -- Slab Chest
  64.  
  65. scX = -2
  66. scY = 0
  67. scZ = 0
  68.  
  69. -- Conveyor Chest
  70.  
  71. cvcX = -3
  72. cvcY = 0
  73. cvcZ = 0
  74.  
  75. -- Ladder Chest
  76.  
  77. lcX = -4
  78. lcY = 0
  79. lcZ = 0
  80.  
  81. -- Torch Chest
  82.  
  83. tcX = -5
  84. tcY = 0
  85. tcZ = 0
  86.  
  87. x = gX
  88. y = gY
  89. z = gZ
  90.  
  91. -- The following 'face' directions are relative to the starting position of the turtle in this program
  92.  
  93. north = 0
  94. west = 1
  95. south = 2
  96. east = 3
  97.  
  98. function goToStartPt(data)
  99. length = data[1]
  100. width = data[2]
  101. xOffset = data[3]
  102. zOffset = data[4]
  103. yOffset = data[5]
  104.  
  105. print("l: ", length, ", w: ", width)
  106. if width > 1 then
  107. targetX = center[1] + ((width - 1) / 2) + xOffset
  108. else
  109. targetX = center[1] + xOffset
  110. end
  111. if length > 1 then
  112. targetZ = center[3] - ((length - 1) / 2) + zOffset
  113. else
  114. targetZ = center[3] + zOffset
  115. end
  116.  
  117. targetY = center[2] + yOffset
  118.  
  119. print("xOff: ", xOffset, ", zOff: ", zOffset, ", yOff: ", yOffset)
  120. print("center[2]: ", center[2], " tX: ", targetX, ", tY: ", targetY, ", tZ: ", targetZ)
  121.  
  122. moveTo(targetX, targetY, targetZ)
  123. end
  124.  
  125. function goToStructure(structure)
  126. local x = 0
  127. local y = 0
  128. local z = 0
  129.  
  130. if structure == "origin" then
  131. x = origin[1]
  132. y = origin[2]
  133. z = origin[3]
  134. elseif structure == "tower" then
  135. x = tower[1]
  136. y = tower[2]
  137. z = tower[3]
  138. elseif structure == "base" then
  139. x = base[1]
  140. y = base[2]
  141. z = base[3]
  142. elseif structure == "ladderChute" then
  143. x = ladderChute[1]
  144. y = ladderChute[2]
  145. z = ladderChute[3]
  146. elseif structure == "drainFloor" then
  147. x = drainFloor[1]
  148. y = drainFloor[2]
  149. z = drainFloor[3]
  150. elseif structure == "conveyors" then
  151. x = conveyors[1]
  152. y = conveyors[2]
  153. z = conveyors[3]
  154. elseif structure == "quicksand" then
  155. x = quicksand[1]
  156. y = quicksand[2]
  157. z = quicksand[3]
  158. elseif structure == "chamber" then
  159. x = chamber[1]
  160. y = chamber[2]
  161. z = chamber[3]
  162. elseif structure == "roof" then
  163. x = roof[1]
  164. y = roof[2]
  165. z = roof[3]
  166. end
  167.  
  168. moveTo(x, y, z)
  169. end
  170.  
  171. function moveUp()
  172.  
  173. for i=1,10 do -- Keep trying in case something is temporarily in the way
  174. if turtle.up() then
  175. y = y + 1
  176. break
  177. else
  178. sleep(2)
  179. end
  180. end
  181. end
  182.  
  183. function moveDown()
  184.  
  185. for i=1,10 do -- Keep trying in case something is temporarily in the way
  186. if turtle.down() then
  187. y = y - 1
  188. break
  189. else
  190. sleep(2)
  191. end
  192. end
  193. end
  194.  
  195. function moveTo(X, Y, Z)
  196. print("moveTo(", X, ", ", Y, ", ", Z, ") y: ", y)
  197. if y == nil then print("y is nil") end
  198. if Y == nil then print("Y is nil") end
  199.  
  200. if y ~= Y then
  201. if y < Y then
  202. while y < Y do
  203. moveUp()
  204. end
  205. else
  206. while y > Y do
  207. moveDown()
  208. end
  209. end
  210. end
  211.  
  212. if x ~= X then
  213. if x < X then
  214. setFace(east)
  215. while x < X do
  216. go(1)
  217. end
  218. else
  219. setFace(west)
  220. while x > X do
  221. go(1)
  222. end
  223. end
  224. end
  225.  
  226. if z ~= Z then
  227. if z < Z then
  228. setFace(north)
  229. while z < Z do
  230. go(1)
  231. end
  232. else
  233. setFace(south)
  234. while z > Z do
  235. go(1)
  236. end
  237. end
  238. end
  239. end
  240.  
  241. function goToChest(chest)
  242. if chest == cobbleChest then
  243. moveTo(ccX, ccY, ccZ)
  244. elseif chest == quicksandChest then
  245. moveTo(qcX, qcY, qcZ)
  246. elseif chest == slabChest then
  247. moveTo(scX, scY, scZ)
  248. elseif chest == conveyorChest then
  249. moveTo(cvcX, cvcY, cvcZ)
  250. elseif chest == ladderChest then
  251. moveTo(lcX, lcY, lcZ)
  252. elseif chest == torchChest then
  253. moveTo(tcX, tcY, tcZ)
  254. end
  255. end
  256.  
  257. function setFace(f)
  258. if f == 0 then
  259. if face == 0 then return end
  260. if face == 1 then right() return end
  261. if face == 2 then right() right() return end
  262. if face == 3 then left() return end
  263. end
  264.  
  265. if f == 1 then
  266. if face == 0 then left() return end
  267. if face == 1 then return end
  268. if face == 2 then right() return end
  269. if face == 3 then right() right() return end
  270. end
  271.  
  272. if f == 2 then
  273. if face == 0 then left() left() return end
  274. if face == 1 then left() return end
  275. if face == 2 then return end
  276. if face == 3 then right() return end
  277. end
  278.  
  279. if f == 3 then
  280. if face == 0 then right() return end
  281. if face == 1 then left() left() return end
  282. if face == 2 then left() return end
  283. if face == 3 then return end
  284. end
  285. end
  286.  
  287. function back(nBlocks)
  288. local failed = true
  289.  
  290. for i=1,nBlocks do
  291. for j=1,10 do -- multiple tries in case something is temporarily in the way
  292. if turtle.back() then
  293. failed = false
  294. break
  295. else
  296. sleep(2)
  297. end
  298. end
  299. end
  300.  
  301. if face == north then z = z - nBlocks end
  302. if face == south then z = z + nBlocks end
  303. if face == east then x = x - nBlocks end
  304. if face == west then x = x + nBlocks end
  305. end
  306.  
  307. function go(nBlocks)
  308. local failed = true
  309.  
  310. for i=1,nBlocks do
  311. for j=1,10 do -- multiple tries in case something is temporarily in the way
  312. if turtle.forward() then
  313. failed = false
  314. break
  315. else
  316. sleep(2)
  317. end
  318. end
  319. end
  320. if failed then
  321. return
  322. end
  323.  
  324. if face == north then z = z + nBlocks end
  325. if face == south then z = z - nBlocks end
  326. if face == east then x = x + nBlocks end
  327. if face == west then x = x - nBlocks end
  328. end
  329.  
  330. function left()
  331. if face == 0 then face = 1 turtle.turnLeft() return end
  332. if face == 1 then face = 2 turtle.turnLeft() return end
  333. if face == 2 then face = 3 turtle.turnLeft() return end
  334. if face == 3 then face = 0 turtle.turnLeft() return end
  335. print("function left\(\): Bad face value: ", face)
  336. end
  337.  
  338. function right()
  339. if face == 0 then face = 3 turtle.turnRight() return end
  340. if face == 1 then face = 0 turtle.turnRight() return end
  341. if face == 2 then face = 1 turtle.turnRight() return end
  342. if face == 3 then face = 2 turtle.turnRight() return end
  343. print("function right\(\): Bad face value: ", face)
  344. end
  345.  
  346. function globalHome()
  347. print("globalHome...")
  348. moveTo(gX, gY, gZ)
  349. setFace(north)
  350. end
  351.  
  352. function xzHome()
  353. local X = gX
  354. local Z = gZ
  355.  
  356. if x ~= X then
  357. if x < X then
  358. setFace(east)
  359. while x < X do
  360. go(1)
  361. end
  362. else
  363. setFace(west)
  364. while x > X do
  365. go(1)
  366. end
  367. end
  368. end
  369.  
  370. if z ~= Z then
  371. if z < Z then
  372. setFace(north)
  373. while z < Z do
  374. go(1)
  375. end
  376. else
  377. setFace(south)
  378. while z > Z do
  379. go(1)
  380. end
  381. end
  382. end
  383. end
  384.  
  385. function zxHome()
  386. zHome()
  387. xHome()
  388. end
  389.  
  390. function xHome()
  391. local X = gX
  392.  
  393. if x ~= X then
  394. if x < X then
  395. setFace(east)
  396. while x < X do
  397. go(1)
  398. end
  399. else
  400. setFace(west)
  401. while x > X do
  402. go(1)
  403. end
  404. end
  405. end
  406. end
  407.  
  408. function zHome()
  409. local Z = gZ
  410.  
  411. if z ~= Z then
  412. if z < Z then
  413. setFace(north)
  414. while z < Z do
  415. go(1)
  416. end
  417. else
  418. setFace(south)
  419. while z > Z do
  420. go(1)
  421. end
  422. end
  423. end
  424. end
  425.  
  426. function yHome()
  427. local Y = gY
  428.  
  429. if y ~= Y then
  430. if y < Y then
  431. while y < Y do
  432. turtle.up()
  433. y = y + 1
  434. end
  435. else
  436. while y > Y do
  437. turtle.down()
  438. y = y - 1
  439. end
  440. end
  441. end
  442. end
  443.  
  444. function grabStuff(stuffSlot)
  445. turtle.select(stuffSlot)
  446. turtle.suckDown()
  447. for i=5,16 do
  448. turtle.select(i)
  449. if not turtle.compareTo(stuffSlot) then
  450. turtle.dump()
  451. end
  452. turtle.suckDown()
  453. end
  454. turtle.select(stuffSlot)
  455. turtle.suckDown()
  456. end
  457.  
  458. function dropStuff(stuffSlot)
  459. qty = turtle.getItemCount(stuffSlot) - 1
  460. turtle.dropDown(qty)
  461. for i=5,16 do
  462. turtle.select(i)
  463. if (turtle.compareTo(stuffSlot)) then
  464. turtle.dropDown()
  465. end
  466. end
  467. end
  468.  
  469. function grabCobble()
  470. turtle.select(cobbleSlot)
  471. for i=5,16 do
  472. turtle.suckDown()
  473. qty = turtle.getItemCount(cobbleSlot) - 1
  474. turtle.transferTo(i, qty)
  475. end
  476. end
  477.  
  478. function dropCobble()
  479. qty = turtle.getItemCount(cobbleSlot) - 1
  480. turtle.dropDown(qty)
  481. for i=5,16 do
  482. turtle.select(i)
  483. if (turtle.compareTo(cobbleSlot)) then
  484. turtle.dropDown()
  485. end
  486. end
  487. end
  488.  
  489. function floorHole(length, width)
  490. for i = 1,width do
  491. for j = 1,length do
  492. turtle.digDown()
  493. if j < length then
  494. turtle.forward()
  495. if face == north then
  496. z = z + 1
  497. elseif face == south then
  498. z = z - 1
  499. end
  500. end
  501. end
  502. if i < width then
  503. if face == north then
  504. left()
  505. turtle.forward()
  506. x = x - 1
  507. left()
  508. elseif face == south then
  509. right()
  510. turtle.forward()
  511. x = x - 1
  512. right()
  513. end
  514. end
  515. end
  516. end
  517.  
  518. function nextSpot()
  519. end
  520.  
  521. function sprinkleTorches(length, width, interval)
  522. turtle.up()
  523. y = y + 1
  524. turtle.select(16)
  525. lengthSpan = length - (2 * interval) - 1
  526. widthSpan = width - (2 * interval) - 1
  527.  
  528. left()
  529. for i = 1,interval do
  530. go(1)
  531. end
  532. right()
  533. for i = 1,interval do
  534. go(1)
  535. end
  536. turtle.placeDown()
  537.  
  538. for i = 1,lengthSpan do
  539. go(1)
  540. end
  541. turtle.placeDown()
  542.  
  543. left()
  544. for i = 1,widthSpan do
  545. go(1)
  546. end
  547. turtle.placeDown()
  548.  
  549. left()
  550. for i = 1,lengthSpan do
  551. go(1)
  552. end
  553. turtle.placeDown()
  554.  
  555. left()
  556. for i = 1,widthSpan + interval do
  557. go(1)
  558. end
  559.  
  560. right()
  561. for i = 1,lengthSpan + interval do
  562. go(1)
  563. end
  564.  
  565. turtle.down()
  566. y = y - 1
  567. end
  568.  
  569. function sprinkleSurface(length, width, interval)
  570. totalPlaced = 0
  571.  
  572. turtle.up()
  573. y = y + 1
  574. turtle.select(16)
  575. for i = 1,width do
  576. for j = 1,length do
  577. if j < length then
  578. if (i % interval == 0 and j % interval == 0) then
  579. turtle.placeDown()
  580. end
  581. turtle.forward()
  582. totalPlaced = totalPlaced + 1
  583. if face == north then
  584. z = z + 1
  585. elseif face == south then
  586. z = z - 1
  587. end
  588. end
  589. end
  590. if i < width then
  591. if face == north then
  592. left()
  593. while i % interval ~= 0 do
  594. turtle.forward()
  595. x = x - 1
  596. i = i + 1
  597. end
  598. left()
  599. elseif face == south then
  600. right()
  601. while i % interval ~= 0 do
  602. turtle.forward()
  603. x = x - 1
  604. i = i + 1
  605. end
  606. right()
  607. end
  608. end
  609. end
  610. end
  611.  
  612. function load(chest, startSlot, endSlot)
  613. goToChest(chest)
  614. for slot=startSlot, endSlot do
  615. turtle.select(slot)
  616. turtle.suckDown()
  617. end
  618. end
  619.  
  620. function dump(chest, startSlot, endSlot)
  621. goToChest(chest)
  622. for slot=startSlot, endSlot do
  623. turtle.select(slot)
  624. turtle.dropDown()
  625. end
  626. end
  627.  
  628. saveX = 0
  629. saveY = 0
  630. saveZ = 0
  631. saveFace = 0
  632.  
  633. function saveXYZ()
  634. saveX = x
  635. saveY = y
  636. saveZ = z
  637. saveFace = face
  638. print("Saved xyz as ", saveX, ", ", saveY, ", ", saveZ, ", face: ", saveFace)
  639. end
  640.  
  641. function restoreXYZ()
  642. x = saveX
  643. y = saveY
  644. z = saveZ
  645. face = saveFace
  646. print("Restored xyz as ", x, ", ", y, ", ", z, ", face: ", face)
  647. end
  648.  
  649. function run(script)
  650. saveXYZ()
  651. shell.run(script)
  652. restoreXYZ()
  653. end
  654.  
  655.  
  656. cobbleChest = 1
  657. quicksandChest = 2
  658. conveyorChest = 3
  659. ladderChest = 4
  660. torchChest = 5
  661.  
  662. slabChest = 2
  663.  
  664. cobbleSlot = 1
  665. quicksandSlot = 2
  666. conveyorSlot = 3
  667. torchSlot = 3
  668.  
  669. --grabStuff(cobbleSlot)
  670. --sleep(3)
  671. --dropStuff(cobbleSlot)
  672.  
  673.  
  674.  
  675. -- BUILD SKYSCRAPER QUICKSAND MOB TRAP
  676.  
  677.  
  678. function buildSandTrap()
  679. load(cobbleChest, 1, 8)
  680. load(torchChest, 16, 16)
  681. goToStartPt(base)
  682. run("floor 15 15")
  683. print("Base completed")
  684. setFace(north)
  685. sprinkleTorches(15, 15, 3)
  686. xzHome()
  687. yHome()
  688. dump(cobbleChest, 1, 8)
  689. dump(torchChest, 16, 16)
  690.  
  691. load(cobbleChest, 1, 13)
  692. load(ladderChest, 14, 16)
  693. globalHome()
  694. goToStartPt(ladderChute)
  695. setFace(north)
  696. run("chute -150 true")
  697. z = z - 1 -- The 'chute' program finishes one block back from start
  698. print("Ladder chute completed")
  699. dump(cobbleChest, 1, 13)
  700. dump(ladderChest, 14, 16)
  701.  
  702. load(cobbleChest, 1, 16)
  703. globalHome()
  704. goToStartPt(tower)
  705. run("walls 5 5 40")
  706. z = z - 1 -- The 'walls' program finishes one block back from start
  707. print("Tower completed")
  708. xzHome()
  709. print("xzHome completed")
  710. yHome()
  711. dump(cobbleChest, 1, 16)
  712.  
  713. load(cobbleChest, 1, 8)
  714. goToStartPt(drainFloor)
  715. run("floor 15 15")
  716.  
  717. left()
  718. for i = 1,6 do
  719. go(1)
  720. end
  721. right()
  722. for i = 1,6 do
  723. go(1)
  724. end
  725. floorHole(3, 3)
  726. xzHome()
  727. yHome()
  728. xzHome()
  729. dump(cobbleChest, 1, 8)
  730.  
  731. load(conveyorChest, 1, 3)
  732. goToStartPt(conveyors)
  733. run("fabdrain")
  734. y = y + 1 -- The 'fabdrain' program finishes one block up from start
  735. xzHome()
  736. yHome()
  737. dump(conveyorChest, 1, 3)
  738.  
  739. load(quicksandChest, 1, 3)
  740. goToStartPt(quicksand)
  741. run("floor 13 13")
  742. xzHome()
  743. yHome()
  744. dump(quicksandChest, 1, 3)
  745.  
  746. load(cobbleChest, 1, 12)
  747. goToStartPt(chamber)
  748. run("walls 15 15 7")
  749. z = z - 1 -- The 'walls' program finishes one block back from start
  750. xzHome()
  751. yHome()
  752. dump(cobbleChest, 1, 12)
  753.  
  754. load(cobbleChest, 1, 8)
  755. load(torchChest, 16, 16)
  756. goToStartPt(roof)
  757. run("floor 15 15")
  758. setFace(north)
  759. sprinkleTorches(15, 15, 3)
  760. xzHome()
  761. yHome()
  762. dump(cobbleChest, 1, 8)
  763. dump(torchChest, 16, 16)
  764.  
  765. globalHome()
  766. end
  767.  
  768. torchSlot = 16
  769.  
  770. function goXZ(startFace, newX, newZ)
  771. setFace(startFace)
  772.  
  773. if face == east then
  774. while x > newX do
  775. go(1)
  776. end
  777. elseif face == west then
  778. while x < newX do
  779. go(1)
  780. end
  781. else
  782. end
  783.  
  784. if face == north then
  785. while z < newZ do
  786. go(1)
  787. end
  788. elseif face == south then
  789. while z > newZ do
  790. go(1)
  791. end
  792. else
  793. end
  794. end
  795.  
  796. function goZX(startFace, newX, newZ)
  797. setFace(startFace)
  798.  
  799. if face == north then
  800. while z < newZ do
  801. go(1)
  802. end
  803. elseif face == south then
  804. while z > newZ do
  805. go(1)
  806. end
  807. else
  808. end
  809.  
  810. if face == east then
  811. while x > newX do
  812. go(1)
  813. end
  814. elseif face == west then
  815. while x < newX do
  816. go(1)
  817. end
  818. else
  819. end
  820. end
  821.  
  822. function layTorches(distance, spacing)
  823. turtle.select(torchSlot)
  824.  
  825. for i=1,distance do
  826. if i % spacing == 0 then
  827. turtle.placeDown()
  828. end
  829. if i < distance then
  830. go(1)
  831. end
  832. end
  833. end
  834.  
  835. function lightPlatform()
  836. goToStartPt(platform)
  837. turtle.up()
  838. y = y + 1
  839. turtle.select(torchSlot)
  840.  
  841. setFace(west)
  842. go(3)
  843. setFace(north)
  844. back(1)
  845. layTorches(platform[2], 4)
  846.  
  847. setFace(west)
  848. go(5)
  849. setFace(south)
  850. back(2)
  851. layTorches(11, 4)
  852. turtle.placeDown()
  853.  
  854. setFace(west)
  855. go(2)
  856. setFace(south)
  857. go(8)
  858. setFace(east)
  859. go(1)
  860. turtle.placeDown()
  861. go(2)
  862. turtle.placeDown()
  863.  
  864. -- setFace(south)
  865. -- go(1)
  866. setFace(west)
  867. go(5)
  868. setFace(north)
  869. layTorches(17, 4)
  870.  
  871. setFace(west)
  872. go(4)
  873. setFace(south)
  874. back(2)
  875. layTorches(17, 4)
  876. end
  877.  
  878. function buildMobGrinder()
  879.  
  880. center = {-6, 0, 20}
  881.  
  882. -- length, width, xOffset, zOffset, yOffset
  883.  
  884. base = {21, 23, 0, 0, 160}
  885. platform = {17, 17, 0, -2, base[5]-40}
  886. torch1 = {9, 9, 0, 0, base[5]+1}
  887. torch2 = {17, 17, 0, 0, base[5]+1}
  888. dropTower = {3, 3, 0, 0, platform[5]}
  889. ladderChute1 = {1, 1, 0, -11, 0}
  890. ladderChute2 = {1, 1, -6, 0, platform[5]}
  891. dropChute = {1, 1, 0, -6, platform[5]}
  892. torch3 = {9, 15, -3, -5, platform[5]+1}
  893.  
  894. floorA = {13, 7, 4, 0, base[5]+4}
  895. wallA = {1, 5, 0, 0, floorA[5]}
  896. trapWallsA = {13, 7, 4, 0, floorA[5]}
  897. trapRoofA = {13, 7, 4, 0, floorA[5] + 4}
  898. trapSlabsA = {13, 7, 4, 0, trapRoofA[5] + 1}
  899.  
  900. floorB = {13, 7, -4, 0, base[5] + 4}
  901. wallB = {1, 5, -4, 0, floorB[5]}
  902. trapWallsB = {13, 7, -4, 0, floorB[5]}
  903. trapRoofB = {13, 7, -4, 0, floorB[5] + 4}
  904. trapSlabsB = {13, 7, -4, 0, trapRoofB[5] + 1}
  905.  
  906. drainFloor = {15, 15, 0, 0, 190}
  907. conveyors = {3, 3, 0, -1, 190}
  908. quicksand = {13, 13, 0, 0, 193}
  909. chamber = {15, 15, 0, 0, 190}
  910. roof = {15, 15, 0, 0, 198}
  911.  
  912. -- Begin the build
  913.  
  914.  
  915. -- LADDER CHUTE FROM GROUND TO PLATFORM
  916.  
  917. load(cobbleChest, 1,12)
  918. load(ladderChest, 14, 16)
  919. goToStartPt(ladderChute1)
  920. run("chute " .. -platform[5] .. " true")
  921. z = z - 1 -- The 'chute' program finishes one block back from start
  922. globalHome()
  923. dump(ladderChest, 14, 16)
  924. dump(cobbleChest, 1, 12)
  925.  
  926. -- PLATFORM
  927.  
  928. setFace(north)
  929. load(cobbleChest, 1, 12)
  930. load(torchChest, 16, 16)
  931.  
  932. goToStartPt(platform)
  933. run("floor " .. platform[1] .. " " .. platform[2])
  934.  
  935. -- TORCHES ON PLATFORM
  936.  
  937. lightPlatform()
  938.  
  939. zxHome()
  940. yHome()
  941.  
  942. dump(torchChest, 16, 16)
  943. dump(cobbleChest, 1, 12)
  944.  
  945. -- DROP CHUTE
  946.  
  947. load(cobbleChest, 1, 12)
  948. load(ladderChest, 14, 16)
  949. goToStartPt(dropChute)
  950. setFace(north)
  951. height = platform[5] - base[5]
  952. run("chute " .. height .. " false") -- No ladders needed in drop chute
  953. z = z - 1 -- The 'chute' program finishes one block back from start
  954.  
  955. -- LADDER CHUTE FROM PLATFORM TO BASE
  956.  
  957. goToStartPt(ladderChute2)
  958. setFace(west)
  959. height = platform[5] - base[5]
  960. run("chute " .. height .. " true")
  961. x = x + 1 -- The 'chute' program finishes one block back from start
  962. zxHome()
  963. dump(ladderChest, 15, 16)
  964. dump(cobbleChest, 1, 12)
  965.  
  966. -- BASE
  967.  
  968. load(cobbleChest, 1, 12)
  969. load(torchChest, 16, 16)
  970. goToStartPt(base)
  971. setFace(north)
  972. run("floor " .. base[1] .. " " .. base[2])
  973.  
  974. -- TORCHES ON BASE
  975.  
  976. moveTo(center[1], torch1[5], center[3])
  977. turtle.select(16)
  978. turtle.placeDown()
  979. goToStartPt(torch1)
  980. setFace(north)
  981. run("sprinkle " .. torch1[1] .. " " .. torch1[2])
  982. goToStartPt(torch2)
  983. setFace(north)
  984. run("sprinkle " .. torch2[1] .. " " .. torch2[2])
  985.  
  986. goToStartPt(floorB)
  987. run("floor " .. floorB[1] .. " " .. floorB[2])
  988.  
  989. goToStartPt(floorA)
  990. setFace(north)
  991. run("floor " .. floorA[1] .. " " .. floorA[2])
  992.  
  993. zxHome()
  994. yHome()
  995. dump(cobbleChest, 1, 12)
  996. dump(torchChest, 16, 16)
  997. load(cobbleChest, 1, 16)
  998.  
  999. goToStartPt(wallB)
  1000. setFace(west)
  1001. run("wall 5 3")
  1002. x = x + 1 -- The 'wall' program finishes one block back from start
  1003.  
  1004. goToStartPt(wallA)
  1005. setFace(east)
  1006. run("wall 5 3")
  1007. x = x - 1 -- The 'wall' program finishes one block back from start
  1008.  
  1009. setFace(south)
  1010. go(6)
  1011.  
  1012. goToStartPt(trapWallsB)
  1013. setFace(north)
  1014. run("walls " .. trapWallsB[1] .. " " .. trapWallsB[2] .. " " .. 3)
  1015. z = z - 1 -- The 'walls' program finishes one block back from start
  1016.  
  1017. setFace(south)
  1018. go(1)
  1019. xHome()
  1020.  
  1021. goToStartPt(trapWallsA)
  1022. setFace(north)
  1023. run("walls " .. trapWallsA[1] .. " " .. trapWallsA[2] .. " " .. 3)
  1024. z = z - 1 -- The 'walls' program finishes one block back from start
  1025.  
  1026. goToStartPt(trapRoofB)
  1027. setFace(north)
  1028. run("floor " .. trapRoofB[1] .. " " .. trapRoofB[2])
  1029.  
  1030. goToStartPt(trapRoofA)
  1031. setFace(north)
  1032. run("floor " .. trapRoofA[1] .. " " .. trapRoofA[2])
  1033.  
  1034. zxHome()
  1035. yHome()
  1036. dump(cobbleChest, 1, 16)
  1037.  
  1038. load(slabChest, 1, 3)
  1039. goToStartPt(trapSlabsB)
  1040. setFace(north)
  1041. run("floor " .. trapSlabsB[1] .. " " .. trapSlabsB[2])
  1042.  
  1043. goToStartPt(trapSlabsA)
  1044. setFace(north)
  1045. run("floor " .. trapSlabsA[1] .. " " .. trapSlabsA[2])
  1046.  
  1047. zxHome()
  1048. setFace(north)
  1049. yHome()
  1050.  
  1051. dump(slabChest, 1, 3)
  1052.  
  1053. globalHome()
  1054.  
  1055. end
  1056.  
  1057. function buildWaterHut()
  1058. --[[
  1059. for i=1,6 do
  1060. turtle.down()
  1061. end
  1062. run("floor 5 5")
  1063. run("walls 5 5 3")
  1064. for i=1,4 do
  1065. turtle.up()
  1066. end
  1067. go(1)
  1068. run("floor 5 5")
  1069. --]]
  1070.  
  1071. while turtle.down() do
  1072. y = y - 1
  1073. end
  1074. height = y + 1
  1075. run("chute " .. height)
  1076. back(1)
  1077. yHome()
  1078. end
  1079.  
  1080. -- MAIN PROGRAM
  1081.  
  1082. if nArgs ~= 1 then
  1083. print(usage)
  1084. return
  1085. end
  1086.  
  1087. face = north
  1088.  
  1089. if args[1] == "sandtrap" then
  1090. buildSandTrap()
  1091. elseif args[1] == "mobgrinder" then
  1092. buildMobGrinder()
  1093. elseif args[1] == "waterhut" then
  1094. buildWaterHut()
  1095. else
  1096. print("Unknown structure: \"", args[1], "\"")
  1097. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement