Guest User

Untitled

a guest
Jan 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.81 KB | None | 0 0
  1.  
  2. -- Feel free to change these:
  3. local pulseLength = 0.1
  4. local collectionDelay = 7
  5. local bus
  6. local busOut
  7. local showPrep = true
  8.  
  9. local bc = { --Bus Colour for each machine (Local)
  10. copperCable = colors.orange,
  11. refinedIron = colors.yellow,
  12. rubber = colors.blue,
  13. circuit = colors.pink,
  14. coalDust = colors.red,
  15. generator = colors.magenta,
  16. solarPanel = colors.white,
  17. -- machineBlock = colors.white, --Change Me
  18. ironFurnace = colors.purple,
  19. rpBattery = colors.lightBlue,
  20. }
  21.  
  22. local req = {
  23. copperCable = 0,
  24. redstone = 0,
  25. iron = 0,
  26. refinedIron = 0,
  27. ironFurnace = 0,
  28. goldCable = 0,
  29. tin = 0,
  30. coal = 0,
  31. glass = 0,
  32. coalDust = 0,
  33. rubber = 0,
  34. woodPlanks = 0,
  35. machineBlock = 0,
  36. stickySap = 0,
  37. circuit = 0,
  38. rpBattery = 0,
  39. generator = 0,
  40. copper = 0 }
  41.  
  42. function paws()
  43. print("Paused, press any key except esc to continue")
  44. local key = false -- set Variable
  45. while key == false do -- Loop
  46. test, test2 = os.pullEvent() -- wait for input
  47. if test=="key" then -- check input is keypress
  48. if test2 ~= 1 then -- not ESC, may want to leave terminal paws'd
  49. key = true -- end loop
  50. end
  51. end
  52. end
  53. end
  54.  
  55. function round(num, idp)
  56. local mult = 10^(idp or 0)
  57. return math.floor(num * mult + 0.5) / mult
  58. end
  59.  
  60. function pulse(col, numPulse)
  61. x,y = term.getCursorPos()
  62. x = x + 2
  63. pct = 100 / numPulse
  64. for i = 1,numPulse do
  65. term.setCursorPos(30,y)
  66. write(round((i * pct), 0) .. "% ")
  67. rs.setBundledOutput(bus, col)
  68. sleep(pulseLength)
  69. rs.setBundledOutput(bus, 0)
  70. sleep(pulseLength)
  71. end
  72. end
  73.  
  74. function copperCable(num)
  75. -- if num < 6 then num = 6 print("Copper Cable increased to 6") end -- Minimum level of 6 cables
  76. if showPrep then print ("Preparing for "..num.." Copper Cable") end
  77. req.rubber = req.rubber + (num)
  78. rubber(num)
  79. req.copper = req.copper + (num / 2)
  80. end
  81.  
  82. function rubber(num)
  83. -- if num < 3 then num = 3 print("Rubber increased to 3") end -- Minimum level of 3 Rubber
  84. if showPrep then print ("Preparing for "..num.." Rubber") end
  85. req.stickySap = req.stickySap + (num / 3)
  86. end
  87.  
  88. function circuit(num)
  89. if showPrep then print ("Preparing for "..num.." Circuit") end
  90. req.copperCable = req.copperCable + (num * 6)
  91. copperCable(num * 6)
  92. req.redstone = req.redstone + (num * 2)
  93. req.refinedIron = req.refinedIron + (num)
  94. refinedIron(num)
  95. end
  96.  
  97. function refinedIron(num)
  98. if showPrep then print ("Preparing for "..num.." Refined Iron") end
  99. req.iron = req.iron + (num)
  100. end
  101.  
  102. function coalDust(num)
  103. if showPrep then print ("Preparing for "..num.." Coal Dust") end
  104. req.coal = req.coal + (num)
  105. end
  106.  
  107. function rpBattery(num)
  108. if showPrep then print ("Preparing for "..num.." RedPower Battery") end
  109. req.tin = req.tin + (num *4)
  110. req.redstone = req.redstone + (num *2)
  111. req.copperCable = req.copperCable + (num)
  112. copperCable(num)
  113. end
  114.  
  115. function machineBlock(num)
  116. if showPrep then print ("Preparing for "..num.." Machine Block") end
  117. req.refinedIron = req.refinedIron + (num * 8)
  118. refinedIron(num * 8)
  119. end
  120.  
  121. function generator(num)
  122. if showPrep then print ("Preparing for "..num.." Generator") end
  123. req.refinedIron = req.refinedIron + (num * 3)
  124. req.rpBattery = req.rpBattery + (num)
  125. req.ironFurnace = req.ironFurnace + (num)
  126. refinedIron(num * 3)
  127. rpBattery(num)
  128. ironFurnace(num)
  129. end
  130.  
  131. function ironFurnace(num)
  132. if showPrep then print ("Preparing for "..num.." Iron Furnace") end
  133. req.iron = req.iron + (num * 8)
  134. end
  135.  
  136. function solarPanel(num)
  137. if showPrep then print ("Preparing for "..num.." Solar Panel") end
  138. req.circuit = req.circuit + (num * 2)
  139. circuit(num * 2)
  140. req.glass = req.glass + (num * 3)
  141. req.generator = req.generator + num
  142. req.coalDust = req.coalDust + (num * 3)
  143. coalDust(num * 3)
  144. generator(num)
  145. end
  146.  
  147. function goldCable(num)
  148. if showPrep then print ("Preparing for "..num.." Gold Cable") end
  149. if num < 4 then num = 4 print("Gold Cable increased to 4") end -- Minimum level of 4 cables
  150. req.rubber = req.rubber + (num)
  151. rubber(num)
  152. req.gold = req.gold + (num / 4)
  153. end
  154.  
  155. function makeItHappen()
  156. write("\nStage 1 - Transforming Raw Materials")
  157. if req.coalDust ~= 0 then write("\n Coal Dust: ") pulse(bc.coalDust, req.coalDust) end
  158. if req.refinedIron ~= 0 then write("\n Refined Iron: ") pulse(bc.refinedIron, req.refinedIron) end
  159. if req.rubber ~= 0 then write("\n Rubber: ") pulse(bc.rubber, req.rubber) end
  160. write("\nPausing for Collection..")
  161. sleep(collectionDelay)
  162. write("\n\nStage 2 - First Pass")
  163. if req.copperCable ~= 0 then write("\n Copper Cable: ") pulse(bc.copperCable, req.copperCable) end
  164. if req.goldCable ~= 0 then write("\n Gold Cable: ") pulse(bc.goldCable, req.goldCable) end
  165. if req.ironFurnace ~= 0 then write("\n Iron Furnace: ") pulse(bc.ironFurnace, req.ironFurnace) end
  166. if req.machineBlock ~= 0 then write("\n Machine Block: ") pulse(bc.machineBlock, req.machineBlock) end
  167. write("\nPausing for Collection..")
  168. sleep(collectionDelay)
  169. write("\n\nStage 3 - Second Pass")
  170. if req.circuit ~= 0 then write("\n Circuit: ") pulse(bc.circuit, req.circuit) end
  171. if req.rpBattery ~= 0 then write("\n RedPower Battery: ") pulse(bc.rpBattery, req.rpBattery) end
  172. write("\nPausing for Collection..")
  173. sleep(collectionDelay)
  174. write("\n\nStage 4 - Third Pass")
  175. if req.generator ~= 0 then write("\n Generator: ") pulse(bc.generator, req.generator) end
  176. write("\nPausing for Collection..")
  177. sleep(collectionDelay)
  178. write("\n\nStage 5 - Fourth Pass")
  179. if req.solarPanel ~= 0 then write("\n Solar Panel: ") pulse(bc.solarPanel, req.solarPanel) end
  180. write("\nPausing for Collection..")
  181. sleep(collectionDelay)
  182. end
  183.  
  184. tArgs = { ... }
  185. if #tArgs ~= 2 then
  186.  
  187. print("Usage: af <Machine bus side> <output pulse side> <monitor side>")
  188.  
  189. else
  190. mon=peripheral.wrap(tArgs[3])
  191. term.redirect(mon) ]]--
  192. term.clear()
  193. term.setCursorPos(1,1)
  194. bus = tArgs[1]
  195. collect = tArgs[2]
  196. rs.setOutput(collect, true)
  197.  
  198. write("How many Solar Panels boss? ")
  199. req.solarPanel = read()
  200. solarPanel(req.solarPanel)
  201. print ("")
  202. print("You want "..req.solarPanel.." Solar Panels! I'll be needing the following items:")
  203. if req.iron ~= 0 then print("Iron: "..req.iron) end
  204. if req.woodPlanks ~= 0 then print("Wooden Planks (Oak): "..req.woodPlanks) end
  205. if req.stickySap ~= 0 then print("Sticky Sap: "..req.stickySap) end
  206. if req.redstone ~= 0 then print("Redstone: "..req.redstone) end
  207. if req.coal ~= 0 then print("Coal: "..req.coal) end
  208. if req.tin ~= 0 then print("Tin: "..req.tin) end
  209. if req.copper ~= 0 then print("Copper: "..req.copper) end
  210. if req.glass ~= 0 then print("Glass: "..req.glass) end
  211. print("")
  212. write ("Now either type go or exit: ")
  213. input = ""
  214. while true do
  215. if input == "exit" then
  216. break
  217. elseif input == "go" then
  218. makeItHappen()
  219. write("\nDone!")
  220. break
  221. end
  222. input=read()
  223. end
  224. term.restore()
  225. print("\nShutting Down")
  226. rs.setOutput(collect, false)
  227. end
Add Comment
Please, Sign In to add comment