osmarks

fusion reactor monitor

Jun 10th, 2021 (edited)
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local s = "back"
  2. local fr = peripheral.find "nc_fusion_reactor"
  3. local name = ("%s_%s_%d"):format(fr.getFirstFusionFuel(), fr.getSecondFusionFuel(), os.getComputerID())
  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.  
  12. while true do
  13.     local l = fr.getEnergyStored() / fr.getMaxEnergyStored()
  14.     local target_temp = fr.getFusionComboHeatVariable() * NC_HEAT_CONSTANT * 1000
  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
Add Comment
Please, Sign In to add comment