forked from sandalle/minecraft_bigreactor_control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlolmer_bigreactor_monitor_prog.lua
2033 lines (1715 loc) · 89.5 KB
/
lolmer_bigreactor_monitor_prog.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--[[
Program name: Lolmer's EZ-NUKE reactor control system
Version: v0.3.11
Programmer: Lolmer
Minor assistance by Mechaet
Last update: 2014-07-21
Pastebin: http://pastebin.com/fguScPBQ
Description:
This program controls a Big Reactors nuclear reactor in Minecraft with a Computercraft computer, using Computercraft's own wired modem connected to the reactors computer control port.
This program was designed to work with the mods and versions installed on Never Stop Toasting (NST) Diet http://www.technicpack.net/modpack/details/never-stop-toasting-diet.254882 Endeavour: Never Stop Toasting: Diet official Minecraft server http://forums.somethingawful.com/showthread.php?threadid=3603757
To simplify the code and guesswork, I assume the following monitor layout, where each "monitor" listed below is a collection of 3 wide by two high Advanced Monitors:
1) One Advanced Monitor for overall status display plus
one or more Reactors plus
none or more Turbines.
2) One Advanced Monitor for overall status display plus (furthest monitor from computer by cable length)
one Advanced Monitor for each connected Reactor plus (subsequent found monitors)
one Advanced Monitor for each connected Turbine (last group of monitors found).
If you enable debug mode, add one additional Advanced Monitor for #1 or #2.
Notes:
Only one reactor and one, two, and three turbines have been tested with the above, but IN THEORY any number is supported.
Devices are found in the reverse order they are plugged in, so monitor_10 will be found before monitor_9.
Two 15x15x14 Turbines can output 260K RF/t by just one 7^3 (four rods) reactor putting out 4k mB steam.
When using actively cooled reactors with turbines, keep the following in mind:
- 1 mB steam carries up to 10RF of potential energy to extract in a turbine.
- Actively cooled reactors produce steam, not power.
- You will need about 10 mB of water for each 1 mB of steam that you want to create in a 7^3 reactor.
Features:
Configurable min/max energy buffer and min/max temperature via ReactorOptions file.
ReactorOptions is read on start and then current values are saved every program cycle.
Rod Control value in ReactorOptions is only useful for initial start, after that the program saves the current Rod Control average over all Fuel Rods for next boot.
Auto-adjusts control rods per reactor to maintain temperature.
Will display reactor data to all attached monitors of correct dimensions.
For multiple monitors, the first monitor (often last plugged in) is the overall status monitor.
For multiple monitors, the first monitor (often last plugged in) is the overall status monitor.
A new cruise mode from mechaet, ONLINE will be "blue" when active, to keep your actively cooled reactors running smoothly.
GUI Usage:
The "<" and ">" buttons, when right-clicked with the mouse, will decrease and increase, respectively, the values assigned to the monitor:
"Rod (%)" will lower/raise the Reactor Control Rods for that Reactor
"mB/t" will lower/raise the Turbine Flow Rate maximum for that Turbine
"RPM" will lower/raise the target Turbine RPM for that Turbine
Right-clicking between the "<" and ">" (not on them) will disable auto-adjust of that value for attached device.
Right-clicking on the "Enabled" or "Disabled" text for auto-adjust will do the same.
Right-clicking on "ONLINE" or "OFFLINE" at the top-right will toggle the state of attached device.
Default values:
Rod Control: 90% (Let's start off safe and then power up as we can)
Minimum Energy Buffer: 15% (will power on below this value)
Maximum Energy Buffer: 85% (will power off above this value)
Minimum Passive Cooling Temperature: 950^C (will raise control rods below this value)
Maximum Passive Cooling Temperature: 1,400^C (will lower control rods above this value)
Minimum Active Cooling Temperature: 300^C (will raise the control rods below this value)
Maximum Active Cooling Temperature: 420^C (will lower control rods above this value)
Optimal Turbine RPM: 900, 1,800, or 2,700 (divisible by 900)
New user-controlled option for target speed of turbines, defaults to 2726RPM, which is high-optimal.
Requirements:
Advanced Monitor size is X: 29, Y: 12 with a 3x2 size
Computer or Advanced Computer
Modems (not wireless) connecting each of the Computer to both the Advanced Monitor and Reactor Computer Port.
Big Reactors (http://www.big-reactors.com/) 0.3.2A+
Computercraft (http://computercraft.info/) 1.63+
Reset the computer any time number of connected devices change.
Resources:
This script is available from:
http://pastebin.com/fguScPBQ
https://github.com/sandalle/minecraft_bigreactor_control
Start-up script is available from:
http://pastebin.com/ZTMzRLez
https://github.com/sandalle/minecraft_bigreactor_control
Other reactor control program which I based my program on:
http://pastebin.com/aMAu4X5J (ScatmanJohn)
http://pastebin.com/HjUVNDau (version ScatmanJohn based his on)
A simpler Big Reactor control program is available from:
http://pastebin.com/7S5xCvgL (IronClaymore only for passively cooled reactors)
Reactor Computer Port API: http://wiki.technicpack.net/Reactor_Computer_Port
Computercraft API: http://computercraft.info/wiki/Category:APIs
Big Reactors Efficiency, Speculation and Questions! http://www.reddit.com/r/feedthebeast/comments/1vzds0/big_reactors_efficiency_speculation_and_questions/
Big Reactors API code: https://github.com/erogenousbeef/BigReactors/blob/master/erogenousbeef/bigreactors/common/multiblock/tileentity/TileEntityReactorComputerPort.java
Big Reactors API: http://big-reactors.com/cc_api.html
ChangeLog:
0.3.12 - Mechaet's changes:
Redid some typing to correct a bug where the reactors always started with rod control disabled.
0.3.11 - Mechaet's changes:
Cleaned up global variables list
Added in per-device naming (displays a friendly name on the bottom of the monitor if configured in the device options file)
Bigger bypasses of control routines when the control has been overridden
Individual config files for turbines and reactors. Persistent between reboots, remembers your last saved settings.
Cruise mode override bypass
Changing flow rate no longer toggles flow rate override on and off. Changing the flow rate clearly indicates intent, so we put the override flag on and leave it there.
Changed the rate at which the regular algorithm adjusts reactor rod control rates. Instead of being 1:1 we now move at 1:5 speed because there is a wide loophole where big adjustments can cause a swinging pendulum effect continually missing the target.
0.3.10 - Turbine algorithm pass by Mechaet.
Updated turbine GUI.
Fix single monitor (again) for Issue #22.
0.3.9 - Reactor algorithm pass by Mechaet.
Additional user config options.
Fix multiple reactors and none or more turbines with only one status monitor.
Fix monitor scaling after one was used as debug (or in case of other modifications).
Fix energy/% displays to match Big Reactors' GUI (Issue #9).
Cruise mode implemented, defaults off but is saved between boots.
Always write out found devices on computer terminal.
Much improved round() function from mechaet (Issue #14).
Refactoring pass/algorithm change on the reactor temperature control. Should now adjust in increments to achieve the desired temperature range quicker and more accurately.
Optimal passive-cooled reactor temperature range changed from 850-900 to 950-1400.
Fix display Issue #15.
0.3.8 - Update to ComputerCraft 1.6 API.
0.3.7 - Fix typo when initializing TurbineNames array.
Fix Issue #1, turbine display is using the Reactor buffer size (10M RF) instead of the Turbine buffer size (1M RF).
0.3.6 - Fix multi-reactors displaying on the correct monitors (thanks HybridFusion).
Fix rod auto-adjust text position.
Reactors store 10M RF and Turbines store 1M RF in their buffer.
Add more colour to displayAllStatus().
Sleep for only two seconds instead of five.
Fix getDeviceStoredEnergyBufferPercent() for Reactors storing 10M RF in buffer.
Keep actively cooled reactors between 0-300^C (non-configurable for now).
0.3.5 - Do not discover connected devices every loop - nicer on servers. Reset computer anytime number of connected devices change.
Fix multi-reactor setups to display the additional reactors on monitors, rather than the last one found.
Fix passive reactor display having auto-adjust and energy buffer overwrite each other (removes rod count).
0.3.4 - Fix arithmetic for checking if we have enough monitors for the number of reactors.
Turbines are optimal at 900, 1800, *and* 2700 RPM
Increase loop timer from 1 to 5 to be nicer to servers
0.3.3 - Add Big Reactor Turbine support
First found monitor (appears to be last connected monitor) is used to display status of all found devices (if more than one valid monitor is found)
Display monitor number on top left of each monitor as "M#" to help find which monitor is which.
Enabling debug will use the last monitor found, if more than one, to print out debug info (also written to file)
Add monitor layout requirements to simplify code
Only clear monitors when we're about to use them (e.g. turbine monitors no longer clear, then wait for all reactors to update)
Fix getDeviceStoredEnergyBufferPercent(), was off by a decimal place
Just use first Control Rod level for entire reactor, they are no longer treated individually in BR 0.3
Allow for one monitor for n number of reactors and m number of turbines
Auto-adjust turbine flow rate by 25 mB to keep rotor speed at 900 or 1,800 RPM.
Clicks on monitors relate to what the monitor is showing (e.g. clicking on reactor 1's display won't modify turbine 1's nor reactor 2's values)
Print monitor name and device (reactor|turbine) name in blue to monitor associated for easier design by users.
Remove version number from monitors to free up space for monitor names.
Add option of right-clicking on "Enabled"/"Disabled" of auto-adjust to toggle it.
0.3.2 - Allow for rod control to override (disable) auto-adjust via UI (Rhonyn)
0.3.1 - Add fuel consumption per tick to display
0.3.0 - Add multi-monitor support! Sends one reactor's data to all monitors.
print function now takes table to support optional specified monitor
Set "numRods" every cycle for some people (mechaet)
Don't redirect terminal output with multiple monitor support
Log troubleshooting data to reactorcontrol.log
FC_API no longer used (copied and modified what I needed)
Multi-reactor support is theoretically implemented, but it is UNTESTED!
Updated for Big Reactor 0.3 (no longer works with 0.2)
BR getFuelTemperature() now returns many significant digits, just use math.ceil()
BR 0.3 removed individual rod temperatures, now it's only reactor-level temperature
0.2.4 - Simplify math, don't divide by a simple large number and then multiply by 100 (#/10000000*100)
Fix direct-connected (no modem) devices. getDeviceSide -> FC_API.getDeviceSide (simple as that :))
0.2.3 - Check bounds on reactor.setRodControlLevel(#,#), Big Reactor doesn't check for us.
0.2.2 - Do not auto-start the reactor if it was manually powered off (autoStart=false)
0.2.1 - Lower/raise only the hottest/coldest Control Rod while trying to control the reactor temperature.
"<" Rod Control buttons was off by one (to the left)
0.2.0 - Lolmer Edition :)
Add min/max stored energy percentage (default is 15%/85%), configurable via ReactorOptions file.
No reason to keep burning fuel if our power output is going nowhere. :)
Use variables variable for the title and version.
Try to keep the temperature between configured values (default is 850^C-950^C)
Add Waste and number of Control/Fuel Rods to displayBards()
TODO:
- Save parameters per reactor instead of one global set for all reactors.
- Add min/max RF/t output and have it override temperature concerns (maybe?).
- Add support for wireless modems, see http://computercraft.info/wiki/Modem_%28API%29, will not be secure (anyone can send/listen to your channels)!
- Add support for any sized monitor (minimum 3x3), dynamic allocation/alignment.
- Lookup using pcall for better error handling http://www.computercraft.info/forums2/index.php?/topic/10992-using-pcall/ .
- Update cruise mode to work independently for each actively-cooled reactor.
]]--
-- Some global variables
local progVer = "0.3.12"
local progName = "EZ-NUKE"
local sideClick, xClick, yClick = nil, 0, 0
local loopTime = 2
local controlRodAdjustAmount = 1 -- Default Reactor Rod Control % adjustment amount
local flowRateAdjustAmount = 25 -- Default Turbine Flow Rate in mB adjustment amount
local debugMode = false
-- End multi-reactor cleanup section
local minStoredEnergyPercent = nil -- Max energy % to store before activate
local maxStoredEnergyPercent = nil -- Max energy % to store before shutdown
local monitorList = {} -- Empty monitor array
local monitorNames = {} -- Empty array of monitor names
local reactorList = {} -- Empty reactor array
local reactorNames = {} -- Empty array of reactor names
local turbineList = {} -- Empty turbine array
local turbineNames = {} -- Empty array of turbine names
local turbineMonitorOffset = 0 -- Turbines are assigned monitors after reactors
term.clear()
term.setCursorPos(2,1)
write("Initializing program...\n")
-- File needs to exist for append "a" later and zero it out if it already exists
-- Always initalize this file to avoid confusion with old files and the latest run
local logFile = fs.open("reactorcontrol.log", "w")
if logFile then
logFile.writeLine("Minecraft time: Day "..os.day().." at "..textutils.formatTime(os.time(),true))
logFile.close()
else
error("Could not open file reactorcontrol.log for writing.")
end
-- Helper functions
local function printLog(printStr)
if debugMode then
-- If multiple monitors, use the last monitor for debugging if debug is enabled
if #monitorList > 1 then
term.redirect(monitorList[#monitorList]) -- Redirect to last monitor for debugging
monitorList[#monitorList].setTextScale(0.5) -- Fit more logs on screen
write(printStr.."\n") -- May need to use term.scroll(x) if we output too much, not sure
term.native()
end -- if #monitorList > 1 then
local logFile = fs.open("reactorcontrol.log", "a") -- See http://computercraft.info/wiki/Fs.open
if logFile then
logFile.writeLine(printStr)
logFile.close()
else
error("Cannot open file reactorcontrol.log for appending!")
end -- if logFile then
end -- if debugMode then
end -- function printLog(printStr)
-- Trim a string
function stringTrim(s)
assert(s ~= nil, "String can't be nil")
return(string.gsub(s, "^%s*(.-)%s*$", "%1"))
end
config = {}
-- Save a table into a config file
-- path: path of the file to write
-- tab: table to save
config.save = function(path, tab)
printLog("Save function called for config for "..path.." EOL")
assert(path ~= nil, "Path can't be nil")
assert(type(tab) == "table", "Second parameter must be a table")
local f = io.open(path, "w")
local i = 0
for key, value in pairs(tab) do
if i ~= 0 then
f:write("\n")
end
f:write("["..key.."]".."\n")
for key2, value2 in pairs(tab[key]) do
key2 = stringTrim(key2)
--doesn't like boolean values
if (type(value2) ~= "boolean") then
value2 = stringTrim(value2)
else
value2 = tostring(value2)
end
key2 = key2:gsub(";", "\\;")
key2 = key2:gsub("=", "\\=")
value2 = value2:gsub(";", "\\;")
value2 = value2:gsub("=", "\\=")
f:write(key2.."="..value2.."\n")
end
i = i + 1
end
f:close()
end --config.save = function(path, tab)
-- Load a config file
-- path: path of the file to read
config.load = function(path)
printLog("Load function called for config for "..path.." EOL")
assert(path ~= nil, "Path can't be nil")
local f = fs.open(path, "r")
if f ~= nil then
local tab = {}
local line = ""
local newLine
local i
local currentTag = nil
local found = false
local pos = 0
while line ~= nil do
found = false
line = line:gsub("\\;", "#_!36!_#") -- to keep \;
line = line:gsub("\\=", "#_!71!_#") -- to keep \=
if line ~= "" then
-- Delete comments
newLine = line
line = ""
for i=1, string.len(newLine) do
if string.sub(newLine, i, i) ~= ";" then
line = line..newLine:sub(i, i)
else
break
end
end
line = stringTrim(line)
-- Find tag
if line:sub(1, 1) == "[" and line:sub(line:len(), line:len()) == "]" then
currentTag = stringTrim(line:sub(2, line:len()-1))
tab[currentTag] = {}
found = true
end
-- Find key and values
if not found and line ~= "" then
pos = line:find("=")
if pos == nil then
error("Bad INI file structure")
end
line = line:gsub("#_!36!_#", ";")
line = line:gsub("#_!71!_#", "=")
tab[currentTag][stringTrim(line:sub(1, pos-1))] = stringTrim(line:sub(pos+1, line:len()))
found = true
end
end
line = f.readLine()
end
f:close()
return tab
else
return nil
end
end --config.load = function(path)
-- round() function from mechaet
local function round(num, places)
local mult = 10^places
local addon = nil
if ((num * mult) < 0) then
addon = -.5
else
addon = .5
end
local integer, decimal = math.modf(num*mult+addon)
newNum = integer/mult
printLog("Called round(num="..num..",places="..places..") returns \""..newNum.."\".")
return newNum
end -- function round(num, places)
local function print(printParams)
-- Default to xPos=1, yPos=1, and first monitor
setmetatable(printParams,{__index={xPos=1, yPos=1, monitorIndex=1}})
local printString, xPos, yPos, monitorIndex =
printParams[1], -- Required parameter
printParams[2] or printParams.xPos,
printParams[3] or printParams.yPos,
printParams[4] or printParams.monitorIndex
local monitor = nil
monitor = monitorList[monitorIndex]
if not monitor then
printLog("monitor["..monitorIndex.."] in print() is NOT a valid monitor.")
return -- Invalid monitorIndex
end
monitor.setCursorPos(xPos, yPos)
monitor.write(printString)
end -- function print(printParams)
-- Replaces the one from FC_API (http://pastebin.com/A9hcbZWe) and adding multi-monitor support
local function printCentered(printString, yPos, monitorIndex)
local monitor = nil
monitor = monitorList[monitorIndex]
if not monitor then
printLog("monitor["..monitorIndex.."] in printCentered() is NOT a valid monitor.")
return -- Invalid monitorIndex
end
local width, height = monitor.getSize()
local monitorNameLength = 0
-- Special changes for title bar
if yPos == 1 then
-- Add monitor name to first line
monitorNameLength = monitorNames[monitorIndex]:len()
-- Leave room for "offline" and "online" on the right except for overall status display
if (#monitorList ~= 1) and (monitorIndex ~= 1) then
width = width - 7
end
end
monitor.setCursorPos(math.floor(width/2) - math.ceil(printString:len()/2) + monitorNameLength/2, yPos)
monitor.clearLine()
monitor.write(printString)
monitor.setTextColor(colors.blue)
print{monitorNames[monitorIndex], 1, 1, monitorIndex}
monitor.setTextColor(colors.white)
end -- function printCentered(printString, yPos, monitorIndex)
-- Print text padded from the left side
-- Clear the left side of the screen
local function printLeft(printString, yPos, monitorIndex)
local monitor = nil
monitor = monitorList[monitorIndex]
if not monitor then
printLog("monitor["..monitorIndex.."] in printLeft() is NOT a valid monitor.")
return -- Invalid monitorIndex
end
local gap = 1
local width = monitor.getSize()
-- Clear left-half of the monitor
for curXPos = 1, (width / 2) do
monitor.setCursorPos(curXPos, yPos)
monitor.write(" ")
end
-- Write our string left-aligned
monitor.setCursorPos(1+gap, yPos)
monitor.write(printString)
end
-- Print text padded from the right side
-- Clear the right side of the screen
local function printRight(printString, yPos, monitorIndex)
local monitor = nil
monitor = monitorList[monitorIndex]
if not monitor then
printLog("monitor["..monitorIndex.."] in printRight() is NOT a valid monitor.")
return -- Invalid monitorIndex
end
-- Make sure printString is a string
printString = tostring(printString)
local gap = 1
local width = monitor.getSize()
-- Clear right-half of the monitor
for curXPos = (width/2), width do
monitor.setCursorPos(curXPos, yPos)
monitor.write(" ")
end
-- Write our string right-aligned
monitor.setCursorPos(math.floor(width) - math.ceil(printString:len()+gap), yPos)
monitor.write(printString)
end
-- Replaces the one from FC_API (http://pastebin.com/A9hcbZWe) and adding multi-monitor support
local function clearMonitor(printString, monitorIndex)
local monitor = nil
monitor = monitorList[monitorIndex]
printLog("Called as clearMonitor(printString="..printString..",monitorIndex="..monitorIndex..").")
if not monitor then
printLog("monitor["..monitorIndex.."] in clearMonitor(printString="..printString..",monitorIndex="..monitorIndex..") is NOT a valid monitor.")
return -- Invalid monitorIndex
end
local gap = 2
monitor.clear()
local width, height = monitor.getSize()
monitor.setTextScale(1.0) -- Make sure scale is correct
printCentered(printString, 1, monitorIndex)
monitor.setTextColor(colors.blue)
print{monitorNames[monitorIndex], 1, 1, monitorIndex}
monitor.setTextColor(colors.white)
for i=1, width do
monitor.setCursorPos(i, gap)
monitor.write("-")
end
monitor.setCursorPos(1, gap+1)
end -- function clearMonitor(printString, monitorIndex)
-- Return a list of all connected (including via wired modems) devices of "deviceType"
local function getDevices(deviceType)
printLog("Called as getDevices(deviceType="..deviceType..")")
local deviceName = nil
local deviceIndex = 1
local deviceList, deviceNames = {}, {} -- Empty array, which grows as we need
local peripheralList = peripheral.getNames() -- Get table of connected peripherals
deviceType = deviceType:lower() -- Make sure we're matching case here
for peripheralIndex = 1, #peripheralList do
-- Log every device found
-- printLog("Found "..peripheral.getType(peripheralList[peripheralIndex]).."["..peripheralIndex.."] attached as \""..peripheralList[peripheralIndex].."\".")
if (string.lower(peripheral.getType(peripheralList[peripheralIndex])) == deviceType) then
-- Log devices found which match deviceType and which device index we give them
printLog("Found "..peripheral.getType(peripheralList[peripheralIndex]).."["..peripheralIndex.."] as index \"["..deviceIndex.."]\" attached as \""..peripheralList[peripheralIndex].."\".")
write("Found "..peripheral.getType(peripheralList[peripheralIndex]).."["..peripheralIndex.."] as index \"["..deviceIndex.."]\" attached as \""..peripheralList[peripheralIndex].."\".\n")
deviceNames[deviceIndex] = peripheralList[peripheralIndex]
deviceList[deviceIndex] = peripheral.wrap(peripheralList[peripheralIndex])
deviceIndex = deviceIndex + 1
end
end -- for peripheralIndex = 1, #peripheralList do
return deviceList, deviceNames
end -- function getDevices(deviceType)
-- Draw a line across the entire x-axis
local function drawLine(yPos, monitorIndex)
local monitor = nil
monitor = monitorList[monitorIndex]
if not monitor then
printLog("monitor["..monitorIndex.."] in drawLine() is NOT a valid monitor.")
return -- Invalid monitorIndex
end
local width, height = monitor.getSize()
for i=1, width do
monitor.setCursorPos(i, yPos)
monitor.write("-")
end
end -- function drawLine(yPos,monitorIndex)
-- Display a solid bar of specified color
local function drawBar(startXPos, startYPos, endXPos, endYPos, color, monitorIndex)
local monitor = nil
monitor = monitorList[monitorIndex]
if not monitor then
printLog("monitor["..monitorIndex.."] in drawBar() is NOT a valid monitor.")
return -- Invalid monitorIndex
end
-- PaintUtils only outputs to term., not monitor.
-- See http://www.computercraft.info/forums2/index.php?/topic/15540-paintutils-on-a-monitor/
term.redirect(monitor)
paintutils.drawLine(startXPos, startYPos, endXPos, endYPos, color)
monitor.setBackgroundColor(colors.black) -- PaintUtils doesn't restore the color
term.native()
end -- function drawBar(startXPos, startYPos,endXPos,endYPos,color,monitorIndex)
-- Display single pixel color
local function drawPixel(xPos, yPos, color, monitorIndex)
local monitor = nil
monitor = monitorList[monitorIndex]
if not monitor then
printLog("monitor["..monitorIndex.."] in drawPixel() is NOT a valid monitor.")
return -- Invalid monitorIndex
end
-- PaintUtils only outputs to term., not monitor.
-- See http://www.computercraft.info/forums2/index.php?/topic/15540-paintutils-on-a-monitor/
term.redirect(monitor)
paintutils.drawPixel(xPos, yPos, color)
monitor.setBackgroundColor(colors.black) -- PaintUtils doesn't restore the color
term.native()
end -- function drawPixel(xPos, yPos, color, monitorIndex)
-- End helper functions
-- Then initialize the monitors
local function findMonitors()
-- Empty out old list of monitors
monitorList = {}
printLog("Finding monitors...")
monitorList, monitorNames = getDevices("monitor")
if #monitorList == 0 then
printLog("No monitors found!")
error("Can't find any monitors!")
else
for monitorIndex = 1, #monitorList do
local monitor = nil
monitor = monitorList[monitorIndex]
if not monitor then
printLog("monitorList["..monitorIndex.."] in findMonitors() is NOT a valid monitor.")
break -- Invalid monitorIndex
end
local monitorX, monitorY = monitor.getSize()
printLog("Verifying monitor["..monitorIndex.."] is of size x:"..monitorX.." by y:"..monitorY..".")
-- Check for minimum size to allow for monitor.setTextScale(0.5) to work for 3x2 debugging monitor, changes getSize()
if monitorX < 29 or monitorY < 12 then
term.redirect(monitor)
monitor.clear()
printLog("Removing monitor "..monitorIndex.." for being too small.")
monitor.setCursorPos(1,2)
write("Monitor is the wrong size!\n")
write("Needs to be at least 3x2.")
term.native()
table.remove(monitorList, monitorIndex) -- Remove invalid monitor from list
if monitorIndex == #monitorList then -- If we're at the end already, break from loop
break
else
monitorIndex = monitorIndex - 1 -- We just removed an element
end -- if monitorIndex == #monitorList then
end -- if monitorX ~= 29 or monitorY ~= 12 then
end -- for monitorIndex = 1, #monitorList do
end -- if #monitorList == 0 then
printLog("Found "..#monitorList.." monitor(s) in findMonitors().")
end -- local function findMonitors()
-- Initialize all Big Reactors - Reactors
local function findReactors()
-- Empty out old list of reactors
newReactorList = {}
printLog("Finding reactors...")
newReactorList, reactorNames = getDevices("BigReactors-Reactor")
if #newReactorList == 0 then
printLog("No reactors found!")
error("Can't find any reactors!")
else -- Placeholder
for reactorIndex = 1, #newReactorList do
local reactor = nil
reactor = newReactorList[reactorIndex]
if not reactor then
printLog("reactorList["..reactorIndex.."] in findReactors() is NOT a valid Big Reactor.")
return -- Invalid reactorIndex
else
printLog("reactor["..reactorIndex.."] in findReactors() is a valid Big Reactor.")
--initialize the default table
_G[reactorNames[reactorIndex]] = {}
_G[reactorNames[reactorIndex]]["ReactorOptions"] = {}
_G[reactorNames[reactorIndex]]["ReactorOptions"]["baseControlRodLevel"] = 80
_G[reactorNames[reactorIndex]]["ReactorOptions"]["lastTempPoll"] = 0
_G[reactorNames[reactorIndex]]["ReactorOptions"]["autoStart"] = true
_G[reactorNames[reactorIndex]]["ReactorOptions"]["activeCooled"] = true
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorMaxTemp"] = 1400 --set for passive-cooled, the active-cooled subroutine will correct it
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorMinTemp"] = 1000
_G[reactorNames[reactorIndex]]["ReactorOptions"]["rodOverride"] = false
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorName"] = reactorNames[reactorIndex]
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorCruising"] = false
if reactor.getConnected() then
printLog("reactor["..reactorIndex.."] in findReactors() is connected.")
else
printLog("reactor["..reactorIndex.."] in findReactors() is NOT connected.")
return -- Disconnected reactor
end
end
--failsafe
local tempTable = _G[reactorNames[reactorIndex]]
--check to make sure we get a valid config
if (config.load(reactorNames[reactorIndex]..".options")) ~= nil then
tempTable = config.load(reactorNames[reactorIndex]..".options")
else
--if we don't have a valid config from disk, make a valid config
config.save(reactorNames[reactorIndex]..".options", _G[reactorNames[reactorIndex]])
end
--load values from tempTable, checking for nil values along the way
if tempTable["ReactorOptions"]["baseControlRodLevel"] ~= nil then
_G[reactorNames[reactorIndex]]["ReactorOptions"]["baseControlRodLevel"] = tempTable["ReactorOptions"]["baseControlRodLevel"]
end
if tempTable["ReactorOptions"]["lastTempPoll"] ~= nil then
_G[reactorNames[reactorIndex]]["ReactorOptions"]["lastTempPoll"] = tempTable["ReactorOptions"]["lastTempPoll"]
end
if tempTable["ReactorOptions"]["autoStart"] ~= nil then
_G[reactorNames[reactorIndex]]["ReactorOptions"]["autoStart"] = tempTable["ReactorOptions"]["autoStart"]
end
if tempTable["ReactorOptions"]["activeCooled"] ~= nil then
_G[reactorNames[reactorIndex]]["ReactorOptions"]["activeCooled"] = tempTable["ReactorOptions"]["activeCooled"]
end
if tempTable["ReactorOptions"]["reactorMaxTemp"] ~= nil then
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorMaxTemp"] = tempTable["ReactorOptions"]["reactorMaxTemp"]
end
if tempTable["ReactorOptions"]["reactorMinTemp"] ~= nil then
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorMinTemp"] = tempTable["ReactorOptions"]["reactorMinTemp"]
end
if tempTable["ReactorOptions"]["rodOverride"] ~= nil then
printLog("Got value from config file for Rod Override, the value is: "..tempTable["ReactorOptions"]["rodOverride"].." EOL")
_G[reactorNames[reactorIndex]]["ReactorOptions"]["rodOverride"] = tempTable["ReactorOptions"]["rodOverride"]
end
if tempTable["ReactorOptions"]["reactorName"] ~= nil then
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorName"] = tempTable["ReactorOptions"]["reactorName"]
end
if tempTable["ReactorOptions"]["reactorCruising"] ~= nil then
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorCruising"] = tempTable["ReactorOptions"]["reactorCruising"]
end
--stricter typing, let's set these puppies up with the right type of value.
_G[reactorNames[reactorIndex]]["ReactorOptions"]["baseControlRodLevel"] = tonumber(_G[reactorNames[reactorIndex]]["ReactorOptions"]["baseControlRodLevel"])
_G[reactorNames[reactorIndex]]["ReactorOptions"]["lastTempPoll"] = tonumber(_G[reactorNames[reactorIndex]]["ReactorOptions"]["lastTempPoll"])
if (tostring(_G[reactorNames[reactorIndex]]["ReactorOptions"]["autoStart"]) == "true") then
_G[reactorNames[reactorIndex]]["ReactorOptions"]["autoStart"] = true
else
_G[reactorNames[reactorIndex]]["ReactorOptions"]["autoStart"] = false
end
if (tostring(_G[reactorNames[reactorIndex]]["ReactorOptions"]["activeCooled"]) == "true") then
_G[reactorNames[reactorIndex]]["ReactorOptions"]["activeCooled"] = true
else
_G[reactorNames[reactorIndex]]["ReactorOptions"]["activeCooled"] = false
end
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorMaxTemp"] = tonumber(_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorMaxTemp"])
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorMinTemp"] = tonumber(_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorMinTemp"])
if (tostring(_G[reactorNames[reactorIndex]]["ReactorOptions"]["rodOverride"]) == "true") then
printLog("Setting Rod Override for "..reactorNames[reactorIndex].." to true because value was ".._G[reactorNames[reactorIndex]]["ReactorOptions"]["rodOverride"].." EOL")
_G[reactorNames[reactorIndex]]["ReactorOptions"]["rodOverride"] = true
else
printLog("Setting Rod Override for "..reactorNames[reactorIndex].." to false because value was ".._G[reactorNames[reactorIndex]]["ReactorOptions"]["rodOverride"].." EOL")
_G[reactorNames[reactorIndex]]["ReactorOptions"]["rodOverride"] = false
end
if (tostring(_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorCruising"]) == "true") then
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorCruising"] = true
else
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorCruising"] = false
end
--save one more time, in case we didn't have a complete config file before
config.save(reactorNames[reactorIndex]..".options", _G[reactorNames[reactorIndex]])
end -- for reactorIndex = 1, #newReactorList do
end -- if #newReactorList == 0 then
-- Overwrite old reactor list with the now updated list
reactorList = newReactorList
-- Start turbine monitor offset after reactors get monitors
-- This assumes that there is a monitor for each turbine and reactor, plus the overall monitor display
turbineMonitorOffset = #reactorList + 1 -- #turbineList will start at "1" if turbines found and move us just beyond #reactorList and status monitor range
printLog("Found "..#reactorList.." reactor(s) in findReactors().")
printLog("Set turbineMonitorOffset to "..turbineMonitorOffset.." in findReactors().")
end -- function findReactors()
-- Initialize all Big Reactors - Turbines
local function findTurbines()
-- Empty out old list of turbines
newTurbineList = {}
printLog("Finding turbines...")
newTurbineList, turbineNames = getDevices("BigReactors-Turbine")
if #newTurbineList == 0 then
printLog("No turbines found") -- Not an error
else
for turbineIndex = 1, #newTurbineList do
local turbine = nil
turbine = newTurbineList[turbineIndex]
if not turbine then
printLog("turbineList["..turbineIndex.."] in findTurbines() is NOT a valid Big Reactors Turbine.")
return -- Invalid turbineIndex
else
_G[turbineNames[turbineIndex]] = {}
_G[turbineNames[turbineIndex]]["TurbineOptions"] = {}
_G[turbineNames[turbineIndex]]["TurbineOptions"]["LastSpeed"] = 0
_G[turbineNames[turbineIndex]]["TurbineOptions"]["BaseSpeed"] = 2726
_G[turbineNames[turbineIndex]]["TurbineOptions"]["autoStart"] = true
_G[turbineNames[turbineIndex]]["TurbineOptions"]["LastFlow"] = 2000 --open up with all the steam wide open
_G[turbineNames[turbineIndex]]["TurbineOptions"]["flowOverride"] = false
_G[turbineNames[turbineIndex]]["TurbineOptions"]["turbineName"] = turbineNames[turbineIndex]
printLog("turbineList["..turbineIndex.."] in findTurbines() is a valid Big Reactors Turbine.")
if turbine.getConnected() then
printLog("turbine["..turbineIndex.."] in findTurbines() is connected.")
else
printLog("turbine["..turbineIndex.."] in findTurbines() is NOT connected.")
return -- Disconnected turbine
end
end
--failsafe
local tempTable = _G[turbineNames[turbineIndex]]
--check to make sure we get a valid config
if (config.load(turbineNames[turbineIndex]..".options")) ~= nil then
tempTable = config.load(turbineNames[turbineIndex]..".options")
else
--if we don't have a valid config from disk, make a valid config
config.save(turbineNames[turbineIndex]..".options", _G[turbineNames[turbineIndex]])
end
--load values from tempTable, checking for nil values along the way
if tempTable["TurbineOptions"]["LastSpeed"] ~= nil then
_G[turbineNames[turbineIndex]]["TurbineOptions"]["LastSpeed"] = tempTable["TurbineOptions"]["LastSpeed"]
end
if tempTable["TurbineOptions"]["BaseSpeed"] ~= nil then
_G[turbineNames[turbineIndex]]["TurbineOptions"]["BaseSpeed"] = tempTable["TurbineOptions"]["BaseSpeed"]
end
if tempTable["TurbineOptions"]["autoStart"] ~= nil then
_G[turbineNames[turbineIndex]]["TurbineOptions"]["autoStart"] = tempTable["TurbineOptions"]["autoStart"]
end
if tempTable["TurbineOptions"]["LastFlow"] ~= nil then
_G[turbineNames[turbineIndex]]["TurbineOptions"]["LastFlow"] = tempTable["TurbineOptions"]["LastFlow"]
end
if tempTable["TurbineOptions"]["flowOverride"] ~= nil then
_G[turbineNames[turbineIndex]]["TurbineOptions"]["flowOverride"] = tempTable["TurbineOptions"]["flowOverride"]
end
if tempTable["TurbineOptions"]["turbineName"] ~= nil then
_G[turbineNames[turbineIndex]]["TurbineOptions"]["turbineName"] = tempTable["TurbineOptions"]["turbineName"]
end
--save once more just to make sure we got it
config.save(turbineNames[turbineIndex]..".options", _G[turbineNames[turbineIndex]])
end -- for turbineIndex = 1, #newTurbineList do
-- Overwrite old turbine list with the now updated list
turbineList = newTurbineList
end -- if #newTurbineList == 0 then
printLog("Found "..#turbineList.." turbine(s) in findTurbines().")
end -- function findTurbines()
-- Return current energy buffer in a specific reactor by %
local function getReactorStoredEnergyBufferPercent(reactor)
printLog("Called as getReactorStoredEnergyBufferPercent(reactor).")
if not reactor then
printLog("getReactorStoredEnergyBufferPercent() did NOT receive a valid Big Reactor Reactor.")
return -- Invalid reactorIndex
else
printLog("getReactorStoredEnergyBufferPercent() did receive a valid Big Reactor Reactor.")
end
local energyBufferStorage = reactor.getEnergyStored()
return round(energyBufferStorage/100000, 1) -- (buffer/10000000 RF)*100%
end -- function getReactorStoredEnergyBufferPercent(reactor)
-- Return current energy buffer in a specific Turbine by %
local function getTurbineStoredEnergyBufferPercent(turbine)
printLog("Called as getTurbineStoredEnergyBufferPercent(turbine)")
if not turbine then
printLog("getTurbineStoredEnergyBufferPercent() did NOT receive a valid Big Reactor Turbine.")
return -- Invalid reactorIndex
else
printLog("getTurbineStoredEnergyBufferPercent() did receive a valid Big Reactor Turbine.")
end
local energyBufferStorage = turbine.getEnergyStored()
return round(energyBufferStorage/10000, 1) -- (buffer/1000000 RF)*100%
end -- function getTurbineStoredEnergyBufferPercent(turbine)
local function reactorCruise(cruiseMaxTemp, cruiseMinTemp, reactorIndex)
printLog("Called as reactorCruise(cruiseMaxTemp="..cruiseMaxTemp..",cruiseMinTemp="..cruiseMinTemp..",lastPolledTemp=".._G[reactorNames[reactorIndex]]["ReactorOptions"]["lastTempPoll"]..",reactorIndex="..reactorIndex..").")
--sanitization
local lastPolledTemp = tonumber(_G[reactorNames[reactorIndex]]["ReactorOptions"]["lastTempPoll"])
cruiseMaxTemp = tonumber(cruiseMaxTemp)
cruiseMinTemp = tonumber(cruiseMinTemp)
if ((lastPolledTemp < cruiseMaxTemp) and (lastPolledTemp > cruiseMinTemp)) then
local reactor = nil
reactor = reactorList[reactorIndex]
if not reactor then
printLog("reactor["..reactorIndex.."] in reactorCruise(cruiseMaxTemp="..cruiseMaxTemp..",cruiseMinTemp="..cruiseMinTemp..",lastPolledTemp="..lastPolledTemp..",reactorIndex="..reactorIndex..") is NOT a valid Big Reactor.")
return -- Invalid reactorIndex
else
printLog("reactor["..reactorIndex.."] in reactorCruise(cruiseMaxTemp="..cruiseMaxTemp..",cruiseMinTemp="..cruiseMinTemp..",lastPolledTemp="..lastPolledTemp..",reactorIndex="..reactorIndex..") is a valid Big Reactor.")
if reactor.getConnected() then
printLog("reactor["..reactorIndex.."] in reactorCruise(cruiseMaxTemp="..cruiseMaxTemp..",cruiseMinTemp="..cruiseMinTemp..",lastPolledTemp="..lastPolledTemp..",reactorIndex="..reactorIndex..") is connected.")
else
printLog("reactor["..reactorIndex.."] in reactorCruise(cruiseMaxTemp="..cruiseMaxTemp..",cruiseMinTemp="..cruiseMinTemp..",lastPolledTemp="..lastPolledTemp..",reactorIndex="..reactorIndex..") is NOT connected.")
return -- Disconnected reactor
end -- if reactor.getConnected() then
end -- if not reactor then
local rodPercentage = math.ceil(reactor.getControlRodLevel(0))
local reactorTemp = math.ceil(reactor.getFuelTemperature())
_G[reactorNames[reactorIndex]]["ReactorOptions"]["baseControlRodLevel"] = rodPercentage
if ((reactorTemp < cruiseMaxTemp) and (reactorTemp > cruiseMinTemp)) then
if (reactorTemp < lastPolledTemp) then
rodPercentage = (rodPercentage - 1)
--Boundary check
if rodPercentage < 0 then
reactor.setAllControlRodLevels(0)
else
reactor.setAllControlRodLevels(rodPercentage)
end
else
rodPercentage = (rodPercentage + 1)
--Boundary check
if rodPercentage > 99 then
reactor.setAllControlRodLevels(99)
else
reactor.setAllControlRodLevels(rodPercentage)
end
end -- if (reactorTemp > lastPolledTemp) then
else
--disengage cruise, we've fallen out of the ideal temperature range
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorCruising"] = false
end -- if ((reactorTemp < cruiseMaxTemp) and (reactorTemp > cruiseMinTemp)) then
else
--I don't know how we'd get here, but let's turn the cruise mode off
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorCruising"] = false
end -- if ((lastPolledTemp < cruiseMaxTemp) and (lastPolledTemp > cruiseMinTemp)) then
_G[reactorNames[reactorIndex]]["ReactorOptions"]["lastTempPoll"] = reactorTemp
_G[reactorNames[reactorIndex]]["ReactorOptions"]["activeCooled"] = true
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorMaxTemp"] = cruiseMaxTemp
_G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorMinTemp"] = cruiseMinTemp
config.save(reactorNames[reactorIndex]..".options", _G[reactorNames[reactorIndex]])
end -- function reactorCruise(cruiseMaxTemp, cruiseMinTemp, lastPolledTemp, reactorIndex)
-- Modify reactor control rod levels to keep temperature with defined parameters, but
-- wait an in-game half-hour for the temperature to stabalize before modifying again
local function temperatureControl(reactorIndex)
printLog("Called as temperatureControl(reactorIndex="..reactorIndex..")")
local reactor = nil
reactor = reactorList[reactorIndex]
if not reactor then
printLog("reactor["..reactorIndex.."] in temperatureControl(reactorIndex="..reactorIndex..") is NOT a valid Big Reactor.")
return -- Invalid reactorIndex
else
printLog("reactor["..reactorIndex.."] in temperatureControl(reactorIndex="..reactorIndex..") is a valid Big Reactor.")
if reactor.getConnected() then
printLog("reactor["..reactorIndex.."] in temperatureControl(reactorIndex="..reactorIndex..") is connected.")
else
printLog("reactor["..reactorIndex.."] in temperatureControl(reactorIndex="..reactorIndex..") is NOT connected.")
return -- Disconnected reactor
end -- if reactor.getConnected() then
end
local reactorNum = reactorIndex
local rodPercentage = math.ceil(reactor.getControlRodLevel(0))
local reactorTemp = math.ceil(reactor.getFuelTemperature())
local localMinReactorTemp, localMaxReactorTemp = _G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorMinTemp"], _G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorMaxTemp"]
--bypass if the reactor itself is set to not be auto-controlled
if ((not _G[reactorNames[reactorIndex]]["ReactorOptions"]["rodOverride"]) or (_G[reactorNames[reactorIndex]]["ReactorOptions"]["rodOverride"] == "false")) then
-- No point modifying control rod levels for temperature if the reactor is offline
if reactor.getActive() then
-- Actively cooled reactors should range between 0^C-300^C
-- Actually, active-cooled reactors should range between 300 and 420C (Mechaet)
-- Accordingly I changed the below lines
if reactor.isActivelyCooled() then
-- below was 0
localMinReactorTemp = 300
-- below was 300
localMaxReactorTemp = 420
else
localMinReactorTemp = _G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorMinTemp"]
localMaxReactorTemp = _G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorMaxTemp"]
end
local lastTempPoll = _G[reactorNames[reactorIndex]]["ReactorOptions"]["lastTempPoll"]
if _G[reactorNames[reactorIndex]]["ReactorOptions"]["reactorCruising"] then
--let's bypass all this math and hit the much-more-subtle cruise feature