Advertisement
Guest User

startup

a guest
Jun 26th, 2021
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.12 KB | None | 0 0
  1. -- modified to work with draconic rf storage (trying to determine actual 'gain' from reactor)
  2.  
  3. --Rev. 20210619 wtp
  4. --As my previous paste could be my 'first', this one will become my 1.1 release.
  5.  
  6. --Developed for use on 1.7 Infinity with Draconic Evolution 1.7.10-1.0.2h (Mym.li normal mode)
  7.  
  8. --I've got the main parts I wanted, the setup and considerations are detailed below:
  9.  
  10. --Advanced computer with a Draconic Reactor stabilizer on it's right side.
  11. --Red cage lamp on top (to come on when either containment field or saturation <51%)
  12. -- Note: neither light will light nor flash at 51%, if the last iteration left the red light illuminated it will stay
  13. --       illuminated until either it drops below 51% or rises up or beyond 52% (I call this the 'transition period')
  14. --Green cage lamb on back (to come on with both containment field and saturation >51%)
  15. --A wired modem is on the left side with a cable running up to the Tier-7 Draconic Energy Core Energy Pylon
  16. --advanced monitors 5 wide, three tall stacked below the computer facing the stabilizer I have the flux gate on.
  17. --The Draconic Reactor is connected directly with cryotheum ducts from the stabilizer to the T7 energy 'input'
  18. --then the T7 energy output goes to the reactor injector.
  19. -- The reactor injector flux gate has a redstone signal high at 262,000RF/t and connects back to the injector in
  20. -- reverse containment field mode (three repeaters and a piece of redstone) using 139,700K for my mostly used reactor
  21. -- The stabilizer flux gate to the T7 energy core is currently set at 2,010,000 though of course that took weeks and starts
  22. -- out much lower.
  23. -- Since the T7 fills up and the reactor essentially shuts down, I have a third flux gate 'drain' between the T7
  24. -- energy core and the injector flux gate which is also connected to a modem and wired back to the computer.
  25. -- The idea is to allow both my use and public use to draw on the reactor up to the amount the reactor creates,
  26. -- but to limit the flux gate if that drain gets too high as I've found connecting a new t7 to any of those tessearcts
  27. -- on that flux gate would run out the buffer for the reactor and it would ultimately fail (I lost at least one core this way)
  28.  
  29. -- Its worth acknowledging that the mym.li servers disable the explosion, so while losing the chaos shards hurts,
  30. -- at least you don't lose the rest of the infrastructure.
  31.  
  32. -- Changes for the 19th.
  33. -- Mostly cosmetic, I'm going to start by converting my print redirect output to specific monitor coordinates
  34. -- also better color management, so if the saturation is gaining during the transition period I want that green
  35. -- but the draining warning should be yellow
  36. -- the fluxgate flow override when it kicks in should be red
  37. -- the normal flux gate flow set to the generation power-field drain should be green
  38. -- I may also suppress the maxFieldStrength and maxEnergySaturation as it's static and you sort of get that from the
  39. -- current values and their respective percentages
  40. -- I'm also going to shuffle around and try to put the variable definitions together in a block rather than
  41. -- having code intermixed in the variable initialization block
  42.  
  43. local storage = peripheral.find("draconic_rf_storage")
  44. local monitor = peripheral.wrap("bottom")
  45. local    core = peripheral.wrap("right")
  46. local fluxgate = peripheral.wrap("flux_gate_308") -- dump energy
  47. local fluxgate_out = peripheral.wrap("flux_gate_309") -- from reactor
  48. local powerstate = 0
  49. local x=0
  50. local y=0
  51. local x1=0
  52. local msg="empty"
  53. local fieldStrengthPercent=0
  54. local lastFieldStrengthPercent
  55. local energySaturationPercent=0
  56. local lastEnergySaturationPercent=0 -- last energy saturation
  57. local ecrft=0 -- energy core rf per tick
  58. local adjtimeout=0
  59. local coretemp=0
  60.  
  61. term.redirect(monitor)
  62. term.setBackgroundColor(colors.gray)
  63. fluxgate.setOverrideEnabled(true)  -- required for direct computer control of flux gate flow rate
  64.  
  65. while true do
  66.  
  67. local stab = core.getReactorInfo()
  68.  
  69. y=x
  70. x=storage.getEnergyStored()
  71. powerstate=stab.status
  72.  
  73. monitor.clear()
  74.  
  75. monitor.setTextColor(colors.white)
  76.  
  77. monitor.setCursorPos(15,1)
  78. print("status:")
  79. if powerstate=="online" then
  80.   monitor.setTextColor(colors.green)
  81. else
  82.   monitor.setTextColor(colors.red)
  83. end
  84. monitor.setCursorPos(23,1)
  85. print(powerstate)
  86.  
  87. monitor.setTextColor(colors.white)
  88. monitor.setCursorPos(7,2)
  89. print("generationRate: "..stab.generationRate.." RF/t")
  90.  
  91. monitor.setCursorPos(10,3)
  92. coretemp=stab.temperature
  93. monitor.setTextColor(colors.green)
  94. if (coretemp>7000) then
  95.   monitor.setTextColor(colors.orange)
  96. end
  97. if (coretemp>8000) then
  98.   monitor.setTextColor(colors.purple)
  99. end
  100. print("temperature: "..coretemp)
  101. monitor.setTextColor(colors.white)
  102.  
  103. monitor.setCursorPos(8,4)
  104. print("fieldStrength: "..stab.fieldStrength)
  105.  
  106. -- these two max values are static and don't really tell us anything
  107. --monitor.setCursorPos(5,5)
  108. --print("maxFieldStrength: "..stab.maxFieldStrength)
  109.  
  110. monitor.setCursorPos(7,6)
  111. print("fieldDrainRate: "..stab.fieldDrainRate)
  112.  
  113. monitor.setCursorPos(1,7)
  114. print("Fuel Conversion Rate: "..stab.fuelConversionRate.." nb/t")
  115.  
  116. --monitor.setCursorPos(4,8)
  117. --print("maxFuelConversion: "..stab.maxFuelConversion)
  118.  
  119. local fuelConversionPercent=stab.fuelConversion*100/stab.maxFuelConversion
  120. monitor.setCursorPos(7,9)
  121. print("fuelConversion: "..stab.fuelConversion.."("..math.floor(fuelConversionPercent).."%)")
  122.  
  123. lastEnergySaturationPercent=energySaturationPercent
  124. energySaturationPercent=stab.energySaturation*100/stab.maxEnergySaturation
  125. monitor.setCursorPos(5,10)
  126. print("energySaturation: "..stab.energySaturation.."("..math.floor(energySaturationPercent).."%) "..tonumber(string.format("%.3f",energySaturationPercent-lastEnergySaturationPercent)))
  127. --if energySaturationPercent==50 then
  128. --  stab.setGenerationRate=stab.generationRate+10000
  129. --  sleep(5)
  130. -- end
  131.  
  132. --monitor.setCursorPos(2,11)
  133. --print("maxEnergySaturation: "..stab.maxEnergySaturation)
  134.  
  135. monitor.setCursorPos(8,12)
  136. print("fluxgate flow: "..fluxgate.getFlow())
  137.  
  138. lastFieldStrengthPercent=fieldStrengthPercent
  139. fieldStrengthPercent=stab.fieldStrength*100/stab.maxFieldStrength
  140. monitor.setCursorPos(2,13)
  141. print("Cont. fieldStrength: "..tonumber(string.format("%.3f",(fieldStrengthPercent))).."%".."  ("..fieldStrengthPercent-lastFieldStrengthPercent..")")
  142.  
  143. monitor.setCursorPos(2,15)
  144. print("Energy Core Storage: "..tonumber(string.format("%.3f",x)))
  145. ecrft=((((x-y)/1000/1000)/2)/20) -- there are 20 ticks in a second so you /20 not multiple dufus
  146.  
  147. monitor.setCursorPos(5,16)
  148.  
  149. x1=ecrft
  150. if (x1>999999999) then
  151. -- leave x1 alone for millions
  152.   msg="MRF/t"
  153. end
  154.  
  155. if (x1<10000000000) then
  156.   x1=x1*1000
  157.   msg="KRF/t"
  158. end
  159.  
  160. if (x1<1000000) then
  161.   x1=x1*1000
  162.   msg="RF/t"
  163. end
  164.  
  165. print("Energy Core RF/t: "..x1..msg..", "..math.floor(x*100/2140000000000).."%")
  166. if (fieldStrengthPercent>51 and energySaturationPercent>51) then
  167. --  monitor.setCursorPos(15,14)
  168.   redstone.setOutput("top",false)
  169. end
  170.  
  171. if (adjtimeout>0) then
  172.   adjtimeout=adjtimeout-1
  173.   monitor.setCursorPos(18,14)
  174.   monitor.setTextColor(colors.cyan)
  175.   print("Adjtimeout="..adjtimeout)
  176. end
  177. if (coretemp<7000 and adjtimeout==0 and energySaturationPercent>51) then
  178. -- coretemp temp set to 'save' 7k
  179.     monitor.setCursorPos(18,14)
  180.     monitor.setTextColor(colors.pink)
  181.     print("experimental: adding~10k")
  182.     fluxgate_out.setSignalLowFlow(fluxgate_out.getSignalLowFlow()+10000)
  183.     adjtimeout=120  -- no faster than 1 adj. per 2 min
  184. end
  185.  
  186. --end
  187.  
  188. if (fieldStrengthPercent<51 or energySaturationPercent<51) then
  189.   monitor.setCursorPos(1,14)
  190.   if (lastEnergySaturationPercent<energySaturationPercent) then
  191.     monitor.setTextColor(colors.green)
  192.     print("++++ Correcting")
  193.   elseif (lastEnergySaturationPercent>energySaturationPercent) then
  194.     monitor.setTextColor(colors.yellow)
  195.     print("!!!! Degrading")
  196.   end
  197.   redstone.setOutput("top", not redstone.getOutput("top"))
  198.   redstone.setOutput("back",false)
  199.   if (fieldStrengthPercent<45 or energySaturationPercent<45) then
  200.     redstone.setOutput("top",true)
  201.     core.stopReactor()
  202.     monitor.setCursorPos(20,14)
  203.     monitor.setTextColor(colors.red)
  204.     print("*** REACTOR SCRAM ***")
  205.     term.setBackgroundColor(colors.yellow)
  206.   end
  207. end
  208.  
  209. monitor.setTextColor(colors.white)
  210.  
  211. if (fieldStrengthPercent>51 and energySaturationPercent>51) then
  212.   redstone.setOutput("top",false)
  213.   redstone.setOutput("back",true)
  214. --  redstone.setOutput("back",true) -- redstone.getOutput("top"))
  215. end
  216. -- Energy dump, if core<50% then
  217. -- set fluxgate low flow to core net gain (presuming you're generating at least 500k)
  218.  
  219.   if (x*100/2141200000000)>50 then  -- per above now I'm only setting the output when over 70%
  220.  
  221. -- seems to work more predictably just allowing the generation rate, using the change kept allow massive drops
  222. -- and recover time was poor (even with the 70% safety margin) an empty T7 is really a RF vacuum.
  223. --    fluxgate.setFlowOverride(ecrft*4000)
  224.     fluxgate.setFlowOverride((stab.generationRate-(stab.fieldDrainRate*2))-20500) -- *2 to dump extra above generation range
  225. --  end
  226.   else
  227.     -- Want to let a little through since I rely on this energy to keep my AE2 system operational
  228.     fluxgate.setFlowOverride(500000)
  229.   end
  230.  
  231. sleep(2)
  232. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement