SHOW:
|
|
- or go back to the newest paste.
1 | local s = "back" | |
2 | - | local m = peripheral.find "modem" |
2 | + | local fr = peripheral.find "nc_fusion_reactor" |
3 | - | local name = os.getComputerLabel() |
3 | + | local name = ("%s_%s_%d"):format(fr.getFirstFusionFuel(), fr.getSecondFusionFuel(), os.getComputerID()) |
4 | - | local o = peripheral.wrap(s) |
4 | + | local m = peripheral.find("modem", function(_, o) return o.isWireless() end) |
5 | ||
6 | local function send_metric(...) | |
7 | m.transmit(3054, 3054, {...}) | |
8 | end | |
9 | ||
10 | local NC_HEAT_CONSTANT = 1218.76 | |
11 | - | local l = o.getEnergyStored() / o.getEnergyCapacity() |
11 | + | |
12 | - | send_metric("reactor_energy/" .. name, "energy stored by reactor", "set", l) |
12 | + | |
13 | - | print(l) |
13 | + | local l = fr.getEnergyStored() / fr.getMaxEnergyStored() |
14 | - | rs.setOutput(s, l < 0.8) |
14 | + | local target_temp = fr.getFusionComboHeatVariable() * NC_HEAT_CONSTANT * 1000 |
15 | - | sleep(0.5) |
15 | + | local temp = fr.getTemperature() |
16 | send_metric("reactor_energy/" .. name, "energy stored", "set", l) | |
17 | send_metric("fusion_efficiency/" .. name, "efficiency of fusion reactor 0 to 100", "set", fr.getEfficiency()) | |
18 | send_metric("fusion_temp/" .. name, "temperature of fusion reactor, relative to optimum", "set", temp / target_temp) | |
19 | print(temp / target_temp, l) | |
20 | sleep(1) | |
21 | end |