theCountChuckula

shapes (slight mod for ender)

May 5th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.03 KB | None | 0 0
  1. -- Variable Setup
  2. local argTable = {...}
  3.  
  4. local cmd_line = false
  5. local cmd_line_resume = false
  6. local cmd_line_cost_only = false
  7. local chain_next_shape = false -- this tells goHome() where to end, if true it goes to (0, 0, positionz) if false it goes to (0, 0, 0)
  8. local special_chain = false -- for certain shapes that finish where the next chained shape should start, goHome() will have no affect if true
  9. local cost_only = false
  10. local sim_mode = false
  11.  
  12. local blocks = 0
  13. local fuel = 0
  14.  
  15. local positionx = 0
  16. local positiony = 0
  17. local positionz = 0
  18. local facing = 0
  19.  
  20. local resupply = 0
  21. local choice = ""
  22.  
  23. local temp_prog_table = {}
  24. local prog_table = {} --this is the LOCAL table! used for local stuff only, and is ONLY EVER WRITTEN when sim_mode is FALSE
  25. local prog_file_name = "ShapesProgressFile"
  26.  
  27.  
  28. -- Utility functions
  29.  
  30. function writeOut(message)
  31. print(message)
  32. end
  33.  
  34. function wraprsmodule() --checks for and wraps rs module
  35. if peripheral.getType("left")=="resupply" then
  36. rs=peripheral.wrap("left")
  37. resupply = 1
  38. return true
  39. elseif peripheral.getType("right")=="resupply" then
  40. rs=peripheral.wrap("right")
  41. resupply = 1
  42. return true
  43. else
  44. resupply = 0
  45. return false
  46. end
  47. end
  48.  
  49. function linktorsstation() --links to rs station
  50. if rs.link() then
  51. return true
  52. else
  53. writeOut("Please put Resupply Station to the left of the turtle and press Enter to continue")
  54. io.read()
  55. linktorsstation()
  56. end
  57. end
  58.  
  59. function compareResources()
  60. if (turtle.compareTo(1)==false) then
  61. turtle.drop()
  62. end
  63. end
  64.  
  65. function checkResources()
  66. if resupply == 1 then
  67. if turtle.getItemCount(activeslot) <= 1 then
  68. while not(rs.resupply(1)) do
  69. os.sleep(0.5)
  70. end
  71. end
  72. else
  73. compareResources()
  74. while (turtle.getItemCount(activeslot) <= 1) do
  75. if (activeslot == 15) and (turtle.getItemCount(activeslot)<=1) then
  76. writeOut("Turtle is empty. Attempting to refill from an ender chest")
  77. activeslot = 1
  78. turtle.select(16)
  79. turtle.placeUp()
  80. for s = 1, 14 do
  81. turtle.select(s)
  82. turtle.suckUp()
  83. end
  84. turtle.select(16)
  85. turtle.digUp()
  86. turtle.select(activeslot)
  87. else
  88. activeslot = activeslot+1
  89. writeOut("Turtle slot almost empty, trying slot "..activeslot)
  90. turtle.select(activeslot)
  91. end
  92. compareResources()
  93. os.sleep(0.2)
  94. end
  95. end
  96. end
  97.  
  98. function checkFuel()
  99. if (not(tonumber(turtle.getFuelLevel()) == nil)) then
  100. while turtle.getFuelLevel() < 50 do
  101. writeOut("Turtle almost out of fuel, pausing. Please drop fuel in inventory. And press enter.")
  102. io.read()
  103. turtle.refuel()
  104. end
  105. end
  106. end
  107.  
  108. function placeBlock()
  109. -- Cost calculation mode - don't move
  110. ProgressUpdate()
  111. SimulationCheck()
  112. blocks = blocks + 1
  113. if cost_only then
  114. return
  115. end
  116. if turtle.detectDown() and not turtle.compareDown() then
  117. turtle.digDown()
  118. end
  119. checkResources()
  120. turtle.placeDown()
  121. ProgressUpdate()
  122. WriteProgress()
  123. end
  124.  
  125. -- Navigation features
  126. -- allow the turtle to move while tracking its position
  127. -- this allows us to just give a destination point and have it go there
  128.  
  129. function turnRightTrack()
  130. ProgressUpdate()
  131. SimulationCheck()
  132. facing = facing + 1
  133. if facing >= 4 then
  134. facing = 0
  135. end
  136. if cost_only then
  137. return
  138. end
  139. turtle.turnRight()
  140. ProgressUpdate()
  141. WriteProgress()
  142. end
  143.  
  144. function turnLeftTrack()
  145. ProgressUpdate()
  146. SimulationCheck()
  147. facing = facing - 1
  148. if facing < 0 then
  149. facing = 3
  150. end
  151. if cost_only then
  152. return
  153. end
  154. turtle.turnLeft()
  155. ProgressUpdate()
  156. WriteProgress()
  157. end
  158.  
  159. function turnAroundTrack()
  160. turnLeftTrack()
  161. turnLeftTrack()
  162. end
  163.  
  164. function turnToFace(direction)
  165. if direction >= 4 or direction < 0 then
  166. return false
  167. end
  168. while facing > direction do
  169. turnLeftTrack()
  170. end
  171. return true
  172. end
  173.  
  174. function safeForward()
  175. ProgressUpdate()
  176. SimulationCheck()
  177. fuel = fuel + 1
  178. if cost_only then
  179. return
  180. end
  181. checkFuel()
  182. success = false
  183. while not success do
  184. success = turtle.forward()
  185. if not success then
  186. while turtle.detect() do
  187. if not turtle.dig() then
  188. print("Blocked attempting to move forward.")
  189. print("Please clear and press enter to continue.")
  190. io.read()
  191. end
  192. end
  193. end
  194. end
  195. if facing == 0 then
  196. positiony = positiony + 1
  197. elseif facing == 1 then
  198. positionx = positionx + 1
  199. elseif facing == 2 then
  200. positiony = positiony - 1
  201. elseif facing == 3 then
  202. positionx = positionx - 1
  203. end
  204. end
  205.  
  206. function safeBack()
  207. ProgressUpdate()
  208. SimulationCheck()
  209. fuel = fuel + 1
  210. if cost_only then
  211. return
  212. end
  213. checkFuel()
  214. success = false
  215. while not success do
  216. success = turtle.back()
  217. if not success then
  218. turnAroundTrack()
  219. while turtle.detect() do
  220. if not turtle.dig() then
  221. break
  222. end
  223. end
  224. turnAroundTrack()
  225. success = turtle.back()
  226. if not success then
  227. print("Blocked attempting to move back.")
  228. print("Please clear and press enter to continue.")
  229. io.read()
  230. end
  231. end
  232. end
  233. if facing == 0 then
  234. positiony = positiony - 1
  235. elseif facing == 1 then
  236. positionx = positionx - 1
  237. elseif facing == 2 then
  238. positiony = positiony + 1
  239. elseif facing == 3 then
  240. positionx = positionx + 1
  241. end
  242. end
  243.  
  244. function safeUp()
  245. ProgressUpdate()
  246. SimulationCheck()
  247. fuel = fuel + 1
  248. positionz = positionz + 1
  249. if cost_only then
  250. return
  251. end
  252. checkFuel()
  253. success = false
  254. while not success do
  255. success = turtle.up()
  256. if not success then
  257. while turtle.detectUp() do
  258. if not turtle.digUp() then
  259. print("Blocked attempting to move up.")
  260. print("Please clear and press enter to continue.")
  261. io.read()
  262. end
  263. end
  264. end
  265. end
  266. end
  267.  
  268. function safeDown()
  269. ProgressUpdate()
  270. SimulationCheck()
  271. fuel = fuel + 1
  272. positionz = positionz - 1
  273. if cost_only then
  274. return
  275. end
  276. checkFuel()
  277. success = false
  278. while not success do
  279. success = turtle.down()
  280. if not success then
  281. while turtle.detectDown() do
  282. if not turtle.digDown() then
  283. print("Blocked attempting to move down.")
  284. print("Please clear and press enter to continue.")
  285. io.read()
  286. end
  287. end
  288. end
  289. end
  290. end
  291.  
  292. function moveY(targety)
  293. if targety == positiony then
  294. return
  295. end
  296. if (facing ~= 0 and facing ~= 2) then -- check axis
  297. turnRightTrack()
  298. end
  299. while targety > positiony do
  300. if facing == 0 then
  301. safeForward()
  302. else
  303. safeBack()
  304. end
  305. ProgressUpdate()
  306. WriteProgress()
  307. end
  308. while targety < positiony do
  309. if facing == 2 then
  310. safeForward()
  311. else
  312. safeBack()
  313. end
  314. ProgressUpdate()
  315. WriteProgress()
  316. end
  317. end
  318.  
  319. function moveX(targetx)
  320. if targetx == positionx then
  321. return
  322. end
  323. if (facing ~= 1 and facing ~= 3) then -- check axis
  324. turnRightTrack()
  325. end
  326. while targetx > positionx do
  327. if facing == 1 then
  328. safeForward()
  329. else
  330. safeBack()
  331. end
  332. ProgressUpdate()
  333. WriteProgress()
  334. end
  335. while targetx < positionx do
  336. if facing == 3 then
  337. safeForward()
  338. else
  339. safeBack()
  340. end
  341. ProgressUpdate()
  342. WriteProgress()
  343. end
  344. end
  345.  
  346. --this is unused right now. Ignore. --I've added it to navigateTo() for the future - Happydude11209
  347. function moveZ(targetz) --this function for now, will ONLY be used to CHECK AND RECORD PROGRESS. It does NOTHING currently because targetz ALWAYS equals positionz
  348. if targetz == positionz then
  349. return
  350. end
  351. while targetz < positionz do
  352. safeDown()
  353. ProgressUpdate()
  354. WriteProgress()
  355. end
  356. while targetz > positionz do
  357. safeUp()
  358. ProgressUpdate()
  359. WriteProgress()
  360. end
  361. end
  362.  
  363. -- I *HIGHLY* suggest formatting all shape subroutines to use the format that dome() uses; specifically, navigateTo(x,y,z) placeBlock(). This should ensure proper "data recording" and also makes readability better
  364. function navigateTo(targetx, targety, targetz, moveZFirst)
  365. targetz = targetz or positionz -- if targetz isn't used in the function call it defaults to its current z position, this should make it compatible with all current implementations of navigateTo()
  366. moveZFirst = moveZFirst or false -- default to moving z last, if true is passed as last argument, it moves vertically first
  367.  
  368. if moveZFirst then
  369. moveZ(targetz)
  370. end
  371.  
  372. if facing == 0 or facing == 2 then -- Y axis
  373. moveY(targety)
  374. moveX(targetx)
  375. else
  376. moveX(targetx)
  377. moveY(targety)
  378. end
  379.  
  380. if not moveZFirst then
  381. moveZ(targetz)
  382. end
  383. end
  384.  
  385. function goHome()
  386. if chain_next_shape then
  387. if not special_chain then
  388. navigateTo(0, 0) -- so another program can chain multiple shapes together to create bigger structures
  389. end
  390. else
  391. navigateTo(-1, -1, 0) -- so the user can collect the turtle when it is done1
  392. end
  393. turnToFace(0)
  394. end
  395.  
  396. function round(toBeRounded, decimalPlace) --needed for hexagon and octagon
  397. local multiplier = 10^(decimalPlace or 0)
  398. return math.floor(toBeRounded * multiplier + 0.5) / multiplier
  399. end
  400.  
  401. -- Shape Building Routines
  402.  
  403. function line(length)
  404. if length <= 0 then
  405. error("Error, length can not be 0")
  406. end
  407. local i
  408. for i=1, length do
  409. placeBlock()
  410. if i ~= length then
  411. safeForward()
  412. end
  413. end
  414. end
  415.  
  416. function rectangle(depth, width)
  417. if depth <= 0 then
  418. error("Error, depth can not be 0")
  419. end
  420. if width <= 0 then
  421. error("Error, width can not be 0")
  422. end
  423. local lengths = {depth, width, depth, width }
  424. local j
  425. for j=1,4 do
  426. line(lengths[j])
  427. turnRightTrack()
  428. end
  429. end
  430.  
  431. function square(width)
  432. rectangle(width, width)
  433. end
  434.  
  435. function wall(length, height)
  436. local i
  437. local j
  438. for i = 1, length do
  439. for j = 1, height do
  440. placeBlock()
  441. if j < height then
  442. safeUp()
  443. end
  444. end
  445. safeForward()
  446. for j = 1, height-1 do
  447. safeDown()
  448. end
  449. end
  450. turnLeftTrack()
  451. end
  452.  
  453. function platform(x, y)
  454. local forward = true
  455. for cy = 0, y-1 do
  456. for cx = 0, x-1 do
  457. if forward then
  458. navigateTo(cx, cy)
  459. else
  460. navigateTo(x - cx - 1, cy)
  461. end
  462. placeBlock()
  463. end
  464. if forward then
  465. forward = false
  466. else
  467. forward = true
  468. end
  469. end
  470. end
  471.  
  472. function stair(width, height)
  473. turnRightTrack()
  474. local cx=1
  475. local cy=0
  476. local goforward=0
  477. while cy < height do
  478. while cx < width do
  479. placeBlock()
  480. safeForward()
  481. cx = cx + 1
  482. end
  483. placeBlock()
  484. cx = 1
  485. cy = cy + 1
  486. if cy < height then
  487. if goforward == 1 then
  488. turnRightTrack()
  489. safeUp()
  490. safeForward()
  491. turnRightTrack()
  492. goforward = 0
  493. else
  494. turnLeftTrack()
  495. safeUp()
  496. safeForward()
  497. turnLeftTrack()
  498. goforward = 1
  499. end
  500. end
  501. end
  502. end
  503.  
  504. function circle(radius)
  505. width = radius * 2 + 1
  506. sqrt3 = 3 ^ 0.5
  507. boundary_radius = radius + 1.0
  508. boundary2 = boundary_radius ^ 2
  509. z = radius
  510. cz2 = (radius - z) ^ 2
  511. limit_offset_y = (boundary2 - cz2) ^ 0.5
  512. max_offset_y = math.ceil(limit_offset_y)
  513. -- We do first the +x side, then the -x side to make movement efficient
  514. for side = 0,1 do
  515. -- On the right we go from small y to large y, on the left reversed
  516. -- This makes us travel clockwise around each layer
  517. if (side == 0) then
  518. ystart = radius - max_offset_y
  519. yend = radius + max_offset_y
  520. ystep = 1
  521. else
  522. ystart = radius + max_offset_y
  523. yend = radius - max_offset_y
  524. ystep = -1
  525. end
  526. for y = ystart,yend,ystep do
  527. cy2 = (radius - y) ^ 2
  528. remainder2 = (boundary2 - cz2 - cy2)
  529. if remainder2 >= 0 then
  530. -- This is the maximum difference in x from the centre we can be without definitely being outside the radius
  531. max_offset_x = math.ceil((boundary2 - cz2 - cy2) ^ 0.5)
  532. -- Only do either the +x or -x side
  533. if (side == 0) then
  534. -- +x side
  535. xstart = radius
  536. xend = radius + max_offset_x
  537. else
  538. -- -x side
  539. xstart = radius - max_offset_x
  540. xend = radius - 1
  541. end
  542. -- Reverse direction we traverse xs when in -y side
  543. if y > radius then
  544. temp = xstart
  545. xstart = xend
  546. xend = temp
  547. xstep = -1
  548. else
  549. xstep = 1
  550. end
  551. for x = xstart,xend,xstep do
  552. cx2 = (radius - x) ^ 2
  553. distance_to_centre = (cx2 + cy2 + cz2) ^ 0.5
  554. -- Only blocks within the radius but still within 1 3d-diagonal block of the edge are eligible
  555. if distance_to_centre < boundary_radius and distance_to_centre + sqrt3 >= boundary_radius then
  556. offsets = {{0, 1, 0}, {0, -1, 0}, {1, 0, 0}, {-1, 0, 0}, {0, 0, 1}, {0, 0, -1}}
  557. for i=1,6 do
  558. offset = offsets[i]
  559. dx = offset[1]
  560. dy = offset[2]
  561. dz = offset[3]
  562. if ((radius - (x + dx)) ^ 2 + (radius - (y + dy)) ^ 2 + (radius - (z + dz)) ^ 2) ^ 0.5 >= boundary_radius then
  563. -- This is a point to use
  564. navigateTo(x, y)
  565. placeBlock()
  566. break
  567. end
  568. end
  569. end
  570. end
  571. end
  572. end
  573. end
  574. end
  575.  
  576. function dome(typus, radius)
  577. -- Main dome and sphere building routine
  578. width = radius * 2 + 1
  579. sqrt3 = 3 ^ 0.5
  580. boundary_radius = radius + 1.0
  581. boundary2 = boundary_radius ^ 2
  582. if typus == "dome" then
  583. zstart = radius
  584. elseif typus == "sphere" then
  585. zstart = 0
  586. elseif typus == "bowl" then
  587. zstart = 0
  588. end
  589. if typus == "bowl" then
  590. zend = radius
  591. else
  592. zend = width - 1
  593. end
  594.  
  595. -- This loop is for each vertical layer through the sphere or dome.
  596. for z = zstart,zend do
  597. if not cost_only and z ~= zstart then
  598. safeUp()
  599. end
  600. --writeOut("Layer " .. z)
  601. cz2 = (radius - z) ^ 2
  602. limit_offset_y = (boundary2 - cz2) ^ 0.5
  603. max_offset_y = math.ceil(limit_offset_y)
  604. -- We do first the +x side, then the -x side to make movement efficient
  605. for side = 0,1 do
  606. -- On the right we go from small y to large y, on the left reversed
  607. -- This makes us travel clockwise around each layer
  608. if (side == 0) then
  609. ystart = radius - max_offset_y
  610. yend = radius + max_offset_y
  611. ystep = 1
  612. else
  613. ystart = radius + max_offset_y
  614. yend = radius - max_offset_y
  615. ystep = -1
  616. end
  617. for y = ystart,yend,ystep do
  618. cy2 = (radius - y) ^ 2
  619. remainder2 = (boundary2 - cz2 - cy2)
  620. if remainder2 >= 0 then
  621. -- This is the maximum difference in x from the centre we can be without definitely being outside the radius
  622. max_offset_x = math.ceil((boundary2 - cz2 - cy2) ^ 0.5)
  623. -- Only do either the +x or -x side
  624. if (side == 0) then
  625. -- +x side
  626. xstart = radius
  627. xend = radius + max_offset_x
  628. else
  629. -- -x side
  630. xstart = radius - max_offset_x
  631. xend = radius - 1
  632. end
  633. -- Reverse direction we traverse xs when in -y side
  634. if y > radius then
  635. temp = xstart
  636. xstart = xend
  637. xend = temp
  638. xstep = -1
  639. else
  640. xstep = 1
  641. end
  642.  
  643. for x = xstart,xend,xstep do
  644. cx2 = (radius - x) ^ 2
  645. distance_to_centre = (cx2 + cy2 + cz2) ^ 0.5
  646. -- Only blocks within the radius but still within 1 3d-diagonal block of the edge are eligible
  647. if distance_to_centre < boundary_radius and distance_to_centre + sqrt3 >= boundary_radius then
  648. offsets = {{0, 1, 0}, {0, -1, 0}, {1, 0, 0}, {-1, 0, 0}, {0, 0, 1}, {0, 0, -1}}
  649. for i=1,6 do
  650. offset = offsets[i]
  651. dx = offset[1]
  652. dy = offset[2]
  653. dz = offset[3]
  654. if ((radius - (x + dx)) ^ 2 + (radius - (y + dy)) ^ 2 + (radius - (z + dz)) ^ 2) ^ 0.5 >= boundary_radius then
  655. -- This is a point to use
  656. navigateTo(x, y)
  657. placeBlock()
  658. break
  659. end
  660. end
  661. end
  662. end
  663. end
  664. end
  665. end
  666. end
  667. end
  668.  
  669. function hexagon(sideLength)
  670. local changex = sideLength / 2
  671. local changey = round(math.sqrt(3) * changex, 0)
  672. changex = round(changex, 0)
  673. local counter = 0
  674.  
  675. navigateTo(changex, 0)
  676.  
  677. for currentSide = 1, 6 do
  678. counter = 0
  679.  
  680. if currentSide == 1 then
  681. for placed = 1, sideLength do
  682. navigateTo(positionx + 1, positiony)
  683. placeBlock()
  684. end
  685. elseif currentSide == 2 then
  686. navigateTo(positionx, positiony + 1)
  687. while positiony <= changey do
  688. if counter == 0 or counter == 2 or counter == 4 then
  689. navigateTo(positionx + 1, positiony)
  690. end
  691. placeBlock()
  692. navigateTo(positionx, positiony + 1)
  693. counter = counter + 1
  694. if counter == 5 then
  695. counter = 0
  696. end
  697. end
  698. elseif currentSide == 3 then
  699. while positiony <= (2 * changey) do
  700. if counter == 0 or counter == 2 or counter == 4 then
  701. navigateTo(positionx - 1, positiony)
  702. end
  703. placeBlock()
  704. navigateTo(positionx, positiony + 1)
  705. counter = counter + 1
  706. if counter == 5 then
  707. counter = 0
  708. end
  709. end
  710. elseif currentSide == 4 then
  711. for placed = 1, sideLength do
  712. navigateTo(positionx - 1, positiony)
  713. placeBlock()
  714. end
  715. elseif currentSide == 5 then
  716. navigateTo(positionx, positiony - 1)
  717. while positiony >= changey do
  718. if counter == 0 or counter == 2 or counter == 4 then
  719. navigateTo(positionx - 1, positiony)
  720. end
  721. placeBlock()
  722. navigateTo(positionx, positiony - 1)
  723. counter = counter + 1
  724. if counter == 5 then
  725. counter = 0
  726. end
  727. end
  728. elseif currentSide == 6 then
  729. while positiony >= 0 do
  730. if counter == 0 or counter == 2 or counter == 4 then
  731. navigateTo(positionx + 1, positiony)
  732. end
  733. placeBlock()
  734. navigateTo(positionx, positiony - 1)
  735. counter = counter + 1
  736. if counter == 5 then
  737. counter = 0
  738. end
  739. end
  740. end
  741. end
  742. end
  743.  
  744. function octagon(sideLength)
  745. local sideLength2 = sideLength - 1
  746. local change = round(sideLength2 / math.sqrt(2), 0)
  747.  
  748. navigateTo(change, 0)
  749.  
  750. for currentSide = 1, 8 do
  751. if currentSide == 1 then
  752. for placed = 1, sideLength2 do
  753. navigateTo(positionx + 1, positiony)
  754. placeBlock()
  755. end
  756. elseif currentSide == 2 then
  757. for placed = 1, change do
  758. navigateTo(positionx + 1, positiony + 1)
  759. placeBlock()
  760. end
  761. elseif currentSide == 3 then
  762. for placed = 1, sideLength2 do
  763. navigateTo(positionx, positiony + 1)
  764. placeBlock()
  765. end
  766. elseif currentSide == 4 then
  767. for placed = 1, change do
  768. navigateTo(positionx - 1, positiony + 1)
  769. placeBlock()
  770. end
  771. elseif currentSide == 5 then
  772. for placed = 1, sideLength2 do
  773. navigateTo(positionx - 1, positiony)
  774. placeBlock()
  775. end
  776. elseif currentSide == 6 then
  777. for placed = 1, change do
  778. navigateTo(positionx - 1, positiony - 1)
  779. placeBlock()
  780. end
  781. elseif currentSide == 7 then
  782. for placed = 1, sideLength2 do
  783. navigateTo(positionx, positiony - 1)
  784. placeBlock()
  785. end
  786. elseif currentSide == 8 then
  787. for placed = 1, change do
  788. navigateTo(positionx + 1, positiony - 1)
  789. placeBlock()
  790. end
  791. end
  792. end
  793. end
  794.  
  795. -- Previous Progress Resuming, Sim Functions, Command Line, and File Backend
  796.  
  797. -- will check for a "progress" file.
  798. function CheckForPrevious()
  799. if fs.exists(prog_file_name) then
  800. return true
  801. else
  802. return false
  803. end
  804. end
  805.  
  806. -- creates a progress file, containing a serialized table consisting of the shape type, shape input params, and the last known x, y, and z coords of the turtle (beginning of build project)
  807. function ProgressFileCreate()
  808. if not CheckForPrevious() then
  809. fs.makeDir(prog_file_name)
  810. return true
  811. else
  812. return false
  813. end
  814. end
  815.  
  816. -- deletes the progress file (at the end of the project, also at beginning if user chooses to delete old progress)
  817. function ProgressFileDelete()
  818. if fs.exists(prog_file_name) then
  819. fs.delete(prog_file_name)
  820. return true
  821. else
  822. return false
  823. end
  824. end
  825.  
  826. -- to read the shape params from the file. Shape type, and input params (e.g. "dome" and radius)
  827. function ReadShapeParams()
  828. -- TODO unneeded for now, can just use the table elements directly
  829. end
  830.  
  831. function WriteShapeParams(...) -- the ... lets it take any number of arguments and stores it to the table arg{} | This is still unused anywhere
  832. local paramTable = arg
  833. local param_name = "param"
  834. local param_name2 = param_name
  835. for i,v in ipairs(paramTable) do -- iterates through the args passed to the function, ex. paramTable[1] i = 1 so param_name2 should be "param1", tested and works!
  836. param_name2 = param_name .. i
  837. temp_prog_table[param_name2] = v
  838. prog_table[param_name2] = v
  839. end
  840. -- actually can't do anything right now, because all the param-gathering in Choicefunct() uses different variables -- Working on adding this in (since this can take any number of inputs)
  841. end
  842.  
  843. -- function to write the progress to the file (x, y, z)
  844. function WriteProgress()
  845. local prog_file
  846. local prog_string = ""
  847. --writeOut(textutils.serialize(prog_table))
  848. --ProgressFileCreate()
  849. --writeOut(prog_string)
  850. if sim_mode == false and cost_only == false then
  851. prog_string = textutils.serialize(prog_table) -- put in here to save processing time when in cost_only
  852. prog_file = fs.open(prog_file_name,"w")
  853. prog_file.write(prog_string)
  854. prog_file.close()
  855. end
  856.  
  857. end
  858.  
  859. -- reads progress from file (shape, x, y, z, facing, blocks, param1, param2, param3)
  860. function ReadProgress()
  861. local prog_file = fs.open(prog_file_name, "r")
  862. local read_prog_table = textutils.unserialize(prog_file.readAll())
  863. prog_file.close()
  864. return read_prog_table
  865. end
  866.  
  867. -- compares the progress read from the file to the current sim progress. needs all four params
  868. function CompareProgress() -- return boolean
  869. local prog_table_in = prog_table
  870. local read_prog_table = ReadProgress()
  871. if (prog_table_in.shape == read_prog_table.shape and prog_table_in.x == read_prog_table.x and prog_table_in.y == read_prog_table.y and prog_table_in.blocks == read_prog_table.blocks and prog_table_in.facing == read_prog_table.facing) then
  872. writeOut("All caught up!")
  873. return true -- we're caught up!
  874. else
  875. return false -- not there yet...
  876. end
  877. end
  878.  
  879. function SetSimFlags(b)
  880. sim_mode = b
  881. cost_only = b
  882. if cmd_line_cost_only then
  883. cost_only = true
  884. end
  885. end
  886.  
  887. function SimulationCheck()
  888. if sim_mode then
  889. if CompareProgress() then
  890. SetSimFlags(false) -- if we're caught up, un-set flags
  891. else
  892. SetSimFlags(true) -- if not caught up, just re-affirm that the flags are set
  893. end
  894. end
  895. end
  896.  
  897. function ContinueQuery()
  898. return false -- to disable the resume functionality until it is fixed, allows us to update on pastebin for the new shapes.
  899. -- if cmd_line_resume then
  900. -- return true
  901. -- else
  902. -- if not cmd_line then
  903. -- writeOut("Do you want to continue the last job?")
  904. -- local yes = io.read()
  905. -- if yes == "y" then
  906. -- return true
  907. -- else
  908. -- return false
  909. -- end
  910. -- end
  911. -- end
  912. end
  913.  
  914. function ProgressUpdate() -- this ONLY updates the local table variable. Writing is handled above. -- I want to change this t allow for any number of params
  915. prog_table = {shape = choice, param1 = temp_prog_table.param1, param2 = temp_prog_table.param2, param3 = temp_prog_table.param3, x = positionx, y = positiony, facing = facing, blocks = blocks}
  916. end
  917.  
  918. -- Command Line
  919. function checkCommandLine() --true if arguments were passed
  920. if #argTable > 0 then
  921. cmd_line = true
  922. return true
  923. else
  924. cmd_line = false
  925. return false
  926. end
  927. end
  928.  
  929. function needsHelp() -- true if -h is passed
  930. for i, v in pairs(argTable) do
  931. if v == "-h" or v == "-help" or v == "--help" then
  932. return true
  933. else
  934. return false
  935. end
  936. end
  937. end
  938.  
  939. function setFlagsFromCommandLine() -- sets count_only, chain_next_shape, and sim_mode
  940. for i, v in pairs(argTable) do
  941. if v == "-c" or v == "-cost" or v == "--cost" then
  942. cost_only = true
  943. cmd_line_cost_only = true
  944. writeOut("Cost only mode")
  945. end
  946. if v == "-z" or v == "-chain" or v == "--chain" then
  947. chain_next_shape = true
  948. writeOut("Chained shape mode")
  949. end
  950. if v == "-r" or v == "-resume" or v == "--resume" then
  951. cmd_line_resume = true
  952. writeOut("Resuming")
  953. end
  954. end
  955. end
  956.  
  957. function setTableFromCommandLine() -- sets prog_table and temp_prog_table from command line arguments
  958. prog_table.shape = argTable[1]
  959. temp_prog_table.shape = argTable[1]
  960. local param_name = "param"
  961. local param_name2 = param_name
  962. for i = 2, #argTable do
  963. local add_on = tostring(i - 1)
  964. param_name2 = param_name .. add_on
  965. prog_table[param_name2] = argTable[i]
  966. temp_prog_table[param_name2] = argTable[i]
  967. end
  968. end
  969.  
  970. -- Menu, drawing and Mainfunctions
  971.  
  972. function Choicefunct()
  973. if sim_mode == false and cmd_line == false then -- if we are NOT resuming progress
  974. choice = io.read()
  975. choice = string.lower(choice) -- all checks are aginst lower case words so this is to ensure that
  976. temp_prog_table = {shape = choice}
  977. prog_table = {shape = choice}
  978. if choice == "next" then
  979. WriteMenu2()
  980. choice = io.read()
  981. choice = string.lower(choice) -- all checks are aginst lower case words so this is to ensure that
  982. end
  983. if choice == "end" or choice == "exit" then
  984. writeOut("Goodbye.")
  985. return
  986. end
  987. if choice == "help" then
  988. showHelp()
  989. return
  990. end
  991. if choice == "credits" then
  992. showCredits()
  993. return
  994. end
  995. writeOut("Building a "..choice)
  996. writeOut("Want to just calculate the cost? [y/n]")
  997. local yes = io.read()
  998. if yes == 'y' then
  999. cost_only = true
  1000. end
  1001. elseif sim_mode == true then -- if we ARE resuming progress
  1002. temp_prog_table = ReadProgress()
  1003. choice = temp_prog_table.shape
  1004. choice = string.lower(choice) -- all checks are aginst lower case words so this is to ensure that
  1005. elseif cmd_line == true then -- if running from command line
  1006. choice = temp_prog_table.shape
  1007. choice = string.lower(choice) -- all checks are aginst lower case words so this is to ensure that
  1008. writeOut("Building a "..choice)
  1009. end
  1010. if not cost_only then
  1011. turtle.select(1)
  1012. activeslot = 1
  1013. if turtle.getItemCount(activeslot) == 0 then
  1014. if resupply then
  1015. writeOut("Please put building blocks in the first slot.")
  1016. else
  1017. writeOut("Please put building blocks in the first slot (and more if you need them)")
  1018. end
  1019. while turtle.getItemCount(activeslot) == 0 do
  1020. os.sleep(2)
  1021. end
  1022. end
  1023. else
  1024. activeslot = 1
  1025. end
  1026.  
  1027. if choice == "rectangle" then
  1028. local h = 0
  1029. local v = 0
  1030. if sim_mode == false and cmd_line == false then
  1031. writeOut("How deep do you want it to be?")
  1032. h = io.read()
  1033. writeOut("How wide do you want it to be?")
  1034. v = io.read()
  1035. elseif sim_mode == true or cmd_line == true then
  1036. h = temp_prog_table.param1
  1037. v = temp_prog_table.param2
  1038. end
  1039. h = tonumber(h)
  1040. v = tonumber(v)
  1041. temp_prog_table.param1 = h
  1042. temp_prog_table.param2 = v
  1043. prog_table = {param1 = h, param2 = v} -- THIS is here because we NEED to update the local table!
  1044. rectangle(h, v)
  1045. end
  1046. if choice == "square" then
  1047. local s
  1048. if sim_mode == false and cmd_line == false then
  1049. writeOut("How long does it need to be?")
  1050. s = io.read()
  1051. elseif sim_mode == true or cmd_line == true then
  1052. s = temp_prog_table.param1
  1053. end
  1054. s = tonumber(s)
  1055. temp_prog_table.param1 = s
  1056. prog_table = {param1 = s}
  1057. square(s)
  1058. end
  1059. if choice == "line" then
  1060. local ll = 0
  1061. if sim_mode == false and cmd_line == false then
  1062. writeOut("How long does the line need to be?")
  1063. ll = io.read()
  1064. elseif sim_mode == true or cmd_line == true then
  1065. ll = temp_prog_table.param1
  1066. end
  1067. ll = tonumber(ll)
  1068. temp_prog_table.param1 = ll
  1069. prog_table = {param1 = ll}
  1070. line(ll)
  1071. end
  1072. if choice == "wall" then
  1073. local wl = 0
  1074. local wh = 0
  1075. if sim_mode == false and cmd_line == false then
  1076. writeOut("How long does it need to be?")
  1077. wl = io.read()
  1078. writeOut("How high does it need to be?")
  1079. wh = io.read()
  1080. elseif sim_mode == true or cmd_line == true then
  1081. wl = temp_prog_table.param1
  1082. wh = temp_prog_table.param2
  1083. end
  1084. wl = tonumber(wl)
  1085. wh = tonumber(wh)
  1086. temp_prog_table.param1 = wl
  1087. temp_prog_table.param2 = wh
  1088. if wh <= 0 then
  1089. error("Error, the height can not be zero")
  1090. end
  1091. if wl <= 0 then
  1092. error("Error, the length can not be 0")
  1093. end
  1094. prog_table = {param1 = wl, param2 = wh}
  1095. wall(wl, wh)
  1096. end
  1097. if choice == "platform" then
  1098. local x = 0
  1099. local y = 0
  1100. if sim_mode == false and cmd_line == false then
  1101. writeOut("How wide do you want it to be?")
  1102. x = io.read()
  1103. writeOut("How long do you want it to be?")
  1104. y = io.read()
  1105. elseif sim_mode == true or cmd_line == true then
  1106. x = temp_prog_table.param1
  1107. y = temp_prog_table.param2
  1108. end
  1109. x = tonumber(x)
  1110. y = tonumber(y)
  1111. temp_prog_table.param1 = x
  1112. temp_prog_table.param2 = y
  1113. prog_table = {param1 = x, param2 = y}
  1114. platform(x, y)
  1115. end
  1116. if choice == "stair" then
  1117. local x = 0
  1118. local y = 0
  1119. if sim_mode == false and cmd_line == false then
  1120. writeOut("How wide do you want it to be?")
  1121. x = io.read()
  1122. writeOut("How high do you want it to be?")
  1123. y = io.read()
  1124. elseif sim_mode == true or cmd_line == true then
  1125. x = temp_prog_table.param1
  1126. y = temp_prog_table.param2
  1127. end
  1128. x = tonumber(x)
  1129. y = tonumber(y)
  1130. temp_prog_table.param1 = x
  1131. temp_prog_table.param2 = y
  1132. prog_table = {param1 = x, param2 = y}
  1133. stair(x, y)
  1134. special_chain = true
  1135. end
  1136. if choice == "cuboid" then
  1137. local cl = 0
  1138. local ch = 0
  1139. local hi = 0
  1140. local hollow = ""
  1141. if sim_mode == false and cmd_line == false then
  1142. writeOut("How wide does it need to be?")
  1143. cl = io.read()
  1144. writeOut("How deep does it need to be?")
  1145. ch = io.read()
  1146. writeOut("How high does it need to be?")
  1147. hi = io.read()
  1148. writeOut("Do you want it to be hollow? (y/n)")
  1149. hollow = io.read()
  1150. elseif sim_mode == true or cmd_line == true then
  1151. cl = temp_prog_table.param1
  1152. ch = temp_prog_table.param2
  1153. hi = temp_prog_table.param3
  1154. hollow = temp_prog_table.param4
  1155. end
  1156. cl = tonumber(cl)
  1157. ch = tonumber(ch)
  1158. hi = tonumber(hi)
  1159. temp_prog_table.param1 = cl
  1160. temp_prog_table.param2 = ch
  1161. temp_prog_table.param3 = hi
  1162. temp_prog_table.param4 = hollow
  1163. if hi < 3 then
  1164. hi = 3
  1165. end
  1166. if cl < 3 then
  1167. cl = 3
  1168. end
  1169. if ch < 3 then
  1170. ch = 3
  1171. end
  1172. prog_table = {param1 = cl, param2 = ch, param3 = hi}
  1173. platform(cl, ch)
  1174. while (facing > 0) do
  1175. turnLeftTrack()
  1176. end
  1177. turnAroundTrack()
  1178. if ((ch % 2)==0) then
  1179. -- this is for reorienting the turtle to build the walls correct in relation to the floor and ceiling
  1180. turnLeftTrack()
  1181. end
  1182. if not(hollow == "n") then
  1183. for i = 1, hi-2 do
  1184. safeUp()
  1185. if ((ch % 2)==0) then -- this aswell
  1186. rectangle(cl, ch)
  1187. else
  1188. rectangle(ch, cl)
  1189. end
  1190. end
  1191. else
  1192. for i=1,hi-2 do
  1193. safeUp()
  1194. platform(cl,ch)
  1195. end
  1196. end
  1197. safeUp()
  1198. platform(cl, ch)
  1199. end
  1200. if choice == "1/2-sphere" or choice == "1/2 sphere" then
  1201. local rad = 0
  1202. local half = ""
  1203. if sim_mode == false and cmd_line == false then
  1204. writeOut("What radius do you need it to be?")
  1205. rad = io.read()
  1206. writeOut("What half of the sphere do you want to build?(bottom/top)")
  1207. half = io.read()
  1208. elseif sim_mode == true or cmd_line == true then
  1209. rad = temp_prog_table.param1
  1210. half = temp_prog_table.param2
  1211. end
  1212. rad = tonumber(rad)
  1213. temp_prog_table.param1 = rad
  1214. temp_prog_table.param2 = half
  1215. prog_table = {param1 = rad, param2 = half}
  1216. half = string.lower(half)
  1217. if half == "bottom" then
  1218. dome("bowl", rad)
  1219. else
  1220. dome("dome", rad)
  1221. end
  1222. end
  1223. if choice == "dome" then
  1224. local rad = 0
  1225. if sim_mode == false and cmd_line == false then
  1226. writeOut("What radius do you need it to be?")
  1227. rad = io.read()
  1228. elseif sim_mode == true or cmd_line == true then
  1229. rad = temp_prog_table.param1
  1230. end
  1231. rad = tonumber(rad)
  1232. temp_prog_table.param1 = rad
  1233. prog_table = {param1 = rad}
  1234. dome("dome", rad)
  1235. end
  1236. if choice == "bowl" then
  1237. local rad = 0
  1238. if sim_mode == false and cmd_line == false then
  1239. writeOut("What radius do you need it to be?")
  1240. rad = io.read()
  1241. elseif sim_mode == true or cmd_line == true then
  1242. rad = temp_prog_table.param1
  1243. end
  1244. rad = tonumber(rad)
  1245. temp_prog_table.param1 = rad
  1246. prog_table = {param1 = rad}
  1247. dome("bowl", rad)
  1248. end
  1249. if choice == "circle" then
  1250. local rad = 0
  1251. if sim_mode == false and cmd_line == false then
  1252. writeOut("What radius do you need it to be?")
  1253. rad = io.read()
  1254. elseif sim_mode == true or cmd_line == true then
  1255. rad = temp_prog_table.param1
  1256. end
  1257. rad = tonumber(rad)
  1258. temp_prog_table.param1 = rad
  1259. prog_table = {param1 = rad}
  1260. circle(rad)
  1261. end
  1262. if choice == "cylinder" then
  1263. local rad = 0
  1264. local height = 0
  1265. if sim_mode == false and cmd_line == false then
  1266. writeOut("What radius do you need it to be?")
  1267. rad = io.read()
  1268. writeOut("What height do you need it to be?")
  1269. height = io.read()
  1270. elseif sim_mode == true or cmd_line == true then
  1271. rad = temp_prog_table.param1
  1272. height = temp_prog_table.param2
  1273. end
  1274. rad = tonumber(rad)
  1275. height = tonumber(height)
  1276. temp_prog_table.param1 = rad
  1277. temp_prog_table.param2 = height
  1278. prog_table = {param1 = rad, param2 = height}
  1279. for i = 1, height do
  1280. circle(rad)
  1281. safeUp()
  1282. end
  1283. end
  1284. if choice == "pyramid" then
  1285. local width = 0
  1286. local hollow = ""
  1287. if sim_mode == false and cmd_line == false then
  1288. writeOut("What width/depth do you need it to be?")
  1289. width = io.read()
  1290. writeOut("Do you want it to be hollow [y/n]?")
  1291. hollow = io.read()
  1292. elseif sim_mode == true or cmd_line == true then
  1293. width = temp_prog_table.param1
  1294. hollow = temp_prog_table.param2
  1295. end
  1296. width = tonumber(width)
  1297. temp_prog_table.param1 = width
  1298. temp_prog_table.param2 = hollow
  1299. prog_table = {param1 = width, param2 = hollow}
  1300. if hollow == 'y' or hollow == 'yes' or hollow == 'true' then
  1301. hollow = true
  1302. else
  1303. hollow = false
  1304. end
  1305. height = math.ceil(width / 2)
  1306. for i = 1, height do
  1307. if hollow then
  1308. rectangle(width, width)
  1309. else
  1310. platform(width, width)
  1311. navigateTo(0,0)
  1312. while facing ~= 0 do
  1313. turnRightTrack()
  1314. end
  1315. end
  1316. if i ~= height then
  1317. safeUp()
  1318. safeForward()
  1319. turnRightTrack()
  1320. safeForward()
  1321. turnLeftTrack()
  1322. width = width - 2
  1323. end
  1324. end
  1325. end
  1326. if choice == "sphere" then
  1327. local rad = 0
  1328. if sim_mode == false and cmd_line == false then
  1329. writeOut("What radius do you need it to be?")
  1330. rad = io.read()
  1331. elseif sim_mode == true or cmd_line == true then
  1332. rad = temp_prog_table.param1
  1333. end
  1334. rad = tonumber(rad)
  1335. temp_prog_table.param1 = rad
  1336. prog_table = {param1 = rad}
  1337. dome("sphere", rad)
  1338. end
  1339. if choice == "hexagon" then
  1340. local length = 0
  1341. if sim_mode == false and cmd_line == false then
  1342. writeOut("How long do you need each side to be?")
  1343. length = io.read()
  1344. elseif sim_mode == true or cmd_line == true then
  1345. length = temp_prog_table.param1
  1346. end
  1347. length = tonumber(length)
  1348. temp_prog_table.param1 = length
  1349. prog_table = {param1 = length}
  1350. hexagon(length)
  1351. end
  1352. if choice == "octagon" then
  1353. local length = 0
  1354. if sim_mode == false and cmd_line == false then
  1355. writeOut("How long do you need each side to be?")
  1356. length = io.read()
  1357. elseif sim_mode == true or cmd_line == true then
  1358. length = temp_prog_table.param1
  1359. end
  1360. length = tonumber(length)
  1361. temp_prog_table.param1 = length
  1362. prog_table = {param1 = length}
  1363. octagon(length)
  1364. end
  1365. if choice == "6-prism" or choice == "6 prism" then
  1366. local length = 0
  1367. local height = 0
  1368. if sim_mode == false and cmd_line == false then
  1369. writeOut("How long do you need each side to be?")
  1370. length = io.read()
  1371. writeOut("What height do you need it to be?")
  1372. height = io.read()
  1373. elseif sim_mode == true or cmd_line == true then
  1374. length = temp_prog_table.param1
  1375. height = temp_prog_table.param2
  1376. end
  1377. length = tonumber(length)
  1378. height = tonumber(height)
  1379. temp_prog_table.param1 = length
  1380. temp_prog_table.param2 = height
  1381. prog_table = {param1 = length, param2 = height}
  1382. for i = 1, height do
  1383. hexagon(length)
  1384. safeUp()
  1385. end
  1386. end
  1387. if choice == "8-prism" or choice == "8 prism" then
  1388. local length = 0
  1389. local height = 0
  1390. if sim_mode == false and cmd_line == false then
  1391. writeOut("How long do you need each side to be?")
  1392. length = io.read()
  1393. writeOut("What height do you need it to be?")
  1394. height = io.read()
  1395. elseif sim_mode == true or cmd_line == true then
  1396. length = temp_prog_table.param1
  1397. height = temp_prog_table.param2
  1398. end
  1399. length = tonumber(length)
  1400. height = tonumber(height)
  1401. temp_prog_table.param1 = length
  1402. temp_prog_table.param2 = height
  1403. prog_table = {param1 = length, param2 = height}
  1404. for i = 1, height do
  1405. octagon(length)
  1406. safeUp()
  1407. end
  1408. end
  1409. goHome() -- After all shape building has finished
  1410. writeOut("Done") -- Saves a few lines when put here rather than in each if statement
  1411. end
  1412.  
  1413. function WriteMenu()
  1414. term.clear()
  1415. term.setCursorPos(1, 1)
  1416. writeOut("Shape Maker 1.5 by Keridos/Happydude/pokemane")
  1417. if resupply==1 then
  1418. writeOut("Resupply Mode Active")
  1419. else
  1420. writeOut("")
  1421. end
  1422. if not cmd_line then
  1423. writeOut("What should be built? [page 1/2]");
  1424. writeOut("next for page 2")
  1425. writeOut("+---------+-----------+-------+-------+")
  1426. writeOut("| square | rectangle | wall | line |")
  1427. writeOut("| cylinder| platform | stair | cuboid|")
  1428. writeOut("| pyramid | 1/2-sphere| circle| next |")
  1429. writeOut("+---------+-----------+-------+-------+")
  1430. writeOut("")
  1431. end
  1432. end
  1433.  
  1434. function WriteMenu2()
  1435. term.clear()
  1436. term.setCursorPos(1, 1)
  1437. writeOut("Shape Maker 1.5 by Keridos/Happydude/pokemane")
  1438. if resupply==1 then
  1439. writeOut("Resupply Mode Active")
  1440. else
  1441. writeOut("")
  1442. end
  1443. writeOut("What should be built [page 2/2]?");
  1444. writeOut("")
  1445. writeOut("+---------+-----------+-------+-------+")
  1446. writeOut("| hexagon | octagon | help | |")
  1447. writeOut("| 6-prism | 8-prism | end | |")
  1448. writeOut("| sphere | credits | | |")
  1449. writeOut("+---------+-----------+-------+-------+")
  1450. writeOut("")
  1451. end
  1452.  
  1453. function showHelp()
  1454. writeOut("Usage: shape [shape-type [param1 param2 param3 ...]] [-c] [-h] [-z] [-r]")
  1455. writeOut("-c: Activate cost only mode")
  1456. writeOut("-h: Show this page")
  1457. writeOut("-z: Set chain_next_shape to true, lets you chain together multiple shapes")
  1458. io.read() -- pause here
  1459. writeOut("-r: Resume the last shape if there are any (Note: This is disabled until we can iron out the kinks")
  1460. writeOut("shape-type can be any of the shapes in the menu")
  1461. writeOut("After shape-type input any of the paramaters that you know, the rest should be asked for")
  1462. io.read() -- pause here, too
  1463. end
  1464.  
  1465. function showCredits()
  1466. writeOut("Credits for the shape builder:")
  1467. writeOut("Based on work by Michiel,Vliekkie and Aeolun")
  1468. writeOut("Sphere/dome code by pruby")
  1469. writeOut("Additional improvements by Keridos,Happydude and pokemane")
  1470. io.read() -- pause here, too
  1471. end
  1472.  
  1473. function main()
  1474. if wraprsmodule() then
  1475. linktorsstation()
  1476. end
  1477. if checkCommandLine() then
  1478. if needsHelp() then
  1479. showHelp()
  1480. return -- close the program after help info is shown
  1481. end
  1482. setFlagsFromCommandLine()
  1483. setTableFromCommandLine()
  1484. end
  1485. if CheckForPrevious() then -- will check to see if there was a previous job, and if so, ask if the user would like to re-initialize to current progress status
  1486. if not ContinueQuery() then -- if I don't want to continue
  1487. ProgressFileDelete()
  1488. SetSimFlags(false) -- just to be safe
  1489. WriteMenu()
  1490. Choicefunct()
  1491. else -- if I want to continue
  1492. SetSimFlags(true)
  1493. Choicefunct()
  1494. end
  1495. else
  1496. SetSimFlags(false)
  1497. WriteMenu()
  1498. Choicefunct()
  1499. end
  1500. if (blocks~=0) and (fuel~=0) then -- do not show on help or credits page or when selecting end
  1501. print("Blocks used: " .. blocks)
  1502. print("Fuel used: " .. fuel)
  1503. end
  1504. ProgressFileDelete() -- removes file upon successful completion of a job, or completion of a previous job.
  1505. prog_table = {}
  1506. temp_prog_table = {}
  1507. end
  1508.  
  1509. main()
Advertisement
Add Comment
Please, Sign In to add comment