-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdrac-reactor.lua
52 lines (37 loc) · 1.23 KB
/
drac-reactor.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
-- Code to control a draconic reactor
-- inGate - the flux gate that is sending power into the reactor
-- outGate - the flux gate that is extracting power from the reactor
-- reactor - the stabilizaer that the computer is next to.
reactor = peripheral.wrap("bottom")
inGate = peripheral.wrap("right")
outGate = peripheral.wrap("left")
goalfs = 20
goaltemp = 8000
last_es = 0
last_fs = 0
while true do
info = reactor.getReactorInfo()
temp = info.temperature
maxfs = info.maxFieldStrength
maxes = info.maxEnergySaturation
fs = info.fieldStrength
es = info.energySaturation
if last_es == 0 then last_es = es end
if last_fs == 0 then last_fs = fs end
print(es)
fsp = 100 * fs/maxfs
-- if fsp < 20 then
-- inGate.setSignalLowFlow(inGate.getSignalLowFlow() + 500)
-- elseif fsp > 20 then
-- inGate.setSignalLowFlow(inGate.getSignalLowFlow() - 500)
-- end
inGate.setSignalLowFlow(inGate.getSignalLowFlow() + (20-fsp)*250)
-- input safety
if inGate.getSignalLowFlow() < 100000 then
inGate.setSignalLowFlow(100000)
end
outGate.setSignalLowFlow(info.generationRate * 8000/temp)
last_es = es
last_fs = fs
os.sleep(2)
end