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