Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.77 KB | None | 0 0
  1. --------------------------------------------------
  2. -- Simple Draconic Reactor Control
  3. -- V2.48 Not tested Please use with Caution
  4. -- Made By Daz_X
  5. --------------------------------------------------
  6. --THIS IS STILL BEING TESTED DON'T USE!!
  7. --Works with(1 Ingot,)
  8. --Dont use this reactor with less than 1 ingot of awakened draconium.
  9. --Change the local variables to change how your reactor will run
  10. --Make sure you change the call to match which side the FluxGate and Reactor Stabilizer are on
  11. --Can not guarantee your safety if you exced the maximum amounts
  12. --Does not control the input of Energy to the containment Field that will have to be handled manually
  13. --From my testing it seems for every ingot's worth of fuel you need to have 5000 RF/t going into the Energy Injector ie 1 Ingot= 5000RF 1 block = 45000RF but to be safe add a couple thousand or not whatever just don't kill yourself doing so.
  14.  
  15. local Issue = "None" -- Used to denote why the reactor ceased functioning (None-Nothing wrong) (Temperature-Temperature exceeded limit)
  16. --(Chaos-Levels of Chaos element exceeded limit)(Containment-Containment Field below limit)(Energy-Energy Saturation below limit)
  17. local Incar = 2000 --Reactor output increment amount (Default = 2000)(max Safe ~10000)
  18. local SafeTemp = 8000 --Maximum safe Reactor temperature (Default = 8000)(Safe ~8000)
  19. local SafeFuelCon = 95 --Maximum safe Fuel conversion amount (Default = 90%)(Safe ~95%)
  20. local SafeForce = 15 --Minimum Containment field Strength before Shutdown (Default = 15%)(Safe ~15%)
  21. local SafeEnergy = 15 --Minimum Energy Saturation Level before ShutDown (Default = 18%)(Safe~ 15%)
  22. local EnSatIn = 21 --Energy Saturation Level where the output will begin Increasing According to Incar (Default = 40%)(Safe ~30%)
  23. local EnSatOut = 19 --Energy Saturation Level where the output will begin Decreasing According to Icaar (Default = 28%)(Safe ~20%)
  24.  
  25. ----------------------------------------------------------------------
  26. --Gets all the information about the reactor
  27. function Info()
  28. tbl = peripheral.call("back","getReactorInfo")
  29. for k, v in pairs (tbl) do
  30. if k == "temperature" then
  31. Temp = v
  32. end
  33. if k == "energySaturation" then
  34. EnergySat = v
  35. end
  36. if k == "fieldStrength" then
  37. FieldSt = v
  38. end
  39. if k == "generationRate" then
  40. RFpt = v
  41. end
  42. if k == "fuelConversion" then
  43. FuelCon = v
  44. end
  45. if k == "fuelConversionRateN" then
  46. FuelConR = v
  47. end
  48. if k == "maxFieldStrength" then
  49. MaxSt = v
  50. end
  51. if k == "maxEnergySaturation" then
  52. MaxEn = v
  53. end
  54. if k == "maxFuelConversion" then
  55. MaxCon = v
  56. end
  57. if k == "status" then
  58. Stat = v
  59. end
  60. end
  61. --------------------------------------------------
  62. --All the math that runs the reactor
  63.  
  64. UnSat = EnergySat / MaxEn
  65. EnSat = UnSat * 100
  66. kRFpt = RFpt / 1000
  67. fuel = FuelCon / MaxCon
  68. FuelConv = fuel * 100
  69. FieldPc = FieldSt / MaxSt
  70. Force = FieldPc * 100
  71. MaxPow = MaxCon * 200
  72. PowInt = MaxCon * 28
  73. end
  74. --------------------------------------------------
  75. -- Emergency Shutdown rules
  76.  
  77. function Safety()
  78. if Temp > SafeTemp then --If the Reactor exceeds the temperature safety limits, Reactor Shutdown will be initiated
  79. peripheral.call("back", "stopReactor")
  80. Issue = "Temperature"
  81. print("| REACTOR OVERHEATING")
  82. print("| REACTOR SHUTDOWN INITIATED")
  83. sleep(300)
  84. end
  85. if FuelConv >= SafeFuelCon then --If the amount of Chaos in the Reactor exceeds safety limits, Reactor Shutdown will be initiated
  86. peripheral.call("back", "stopReactor")
  87. Issue = "Chaos"
  88. print("| REACTOR FUEL EXPENDED")
  89. print("| REACTOR SHUTDOWN INITIATED")
  90. sleep(300)
  91. end
  92. if Stat == "online" then
  93.  
  94. if FieldSt <= SafeForce then --If the Containment Field drops below the safety limits, Reactor Shutdown will be initiated
  95. peripheral.call("back", "stopReactor")
  96. Issue = "Containment"
  97. print("| REACTOR CONTAINMENT LOW")
  98. print("| REACTOR SHUTDOWN INITIATED")
  99. sleep(300)
  100. end
  101.  
  102. if EnSat <= SafeEnergy then --If the Energy Buffer drops below the safety limits, Reactor Shutdown will be initiated
  103. peripheral.call("back", "stopReactor")
  104. Issue = "Energy"
  105. print("| REACTOR ENERGY LOW")
  106. print("| REACTOR SHUTDOWN INITIATED")
  107. sleep(300)
  108. end
  109. end
  110. end
  111. --------------------------------------------------
  112. --Power Output Regulation
  113.  
  114. function Power()
  115. PowerGate = peripheral.call("left", "getSignalLowFlow")
  116.  
  117. if EnSat > EnSatIn then
  118. if PowerGate >= MaxPow then
  119. PowerGate = MaxPow
  120. end
  121. if PowerGate < PowInt then
  122. PowerGate = PowInt
  123. end
  124. if Stat == "online" then
  125. if PowerGate < MaxPow then
  126. PowerGate = PowerGate + Incar
  127. end
  128. end
  129. -- print("| Output set to = ", PowerGate)
  130. peripheral.call("left", "setSignalLowFlow", PowerGate)
  131. end
  132.  
  133. if EnSat < EnSatOut then
  134. if Stat == "online" then
  135. PowerGate = PowerGate - Incar
  136. end
  137. -- print("| Output set to = ", PowerGate)
  138. peripheral.call("left", "setSignalLowFlow", PowerGate)
  139. end
  140. end
  141. --------------------------------------------------
  142. --Information Printout
  143.  
  144. function PrintOut()
  145. print()
  146. print("| Reactor Status = "..Stat)
  147. print("| Reactor temperature = "..Temp)
  148. print("| Energy saturation % = "..EnSat)
  149. print("| Field strength % = "..Force)
  150. print("| Chaos Level % = "..FuelConv)
  151. print("| ConvesionRate = "..FuelConR)
  152. print("| Energyproduction kRF/t = "..kRFpt)
  153. print("| Energy Output RF/t = "..PowerGate)
  154. print("| Current Issues = "..Issue)
  155. print("| Maximum Power = "..MaxPow)
  156. --print("| Starter Power = "..PowInt)
  157. end
  158. -----------------------------------------------------------------
  159. --Looping
  160.  
  161. while true do
  162.  
  163. Info()
  164. Safety()
  165. Power()
  166. PrintOut()
  167. sleep(5)
  168.  
  169. Info()
  170. Safety()
  171. PrintOut()
  172. sleep(5)
  173.  
  174. Info()
  175. Safety()
  176. PrintOut()
  177. sleep(5)
  178.  
  179. Info()
  180. Safety()
  181. PrintOut()
  182. sleep(5)
  183.  
  184. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement