osmarks

simpler reactor controller

Jun 7th, 2021 (edited)
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local s = "back"
  2. local m = peripheral.find "modem"
  3. local name = os.getComputerLabel()
  4. local o = peripheral.wrap(s)
  5.  
  6. local function send_metric(...)
  7.     m.transmit(3054, 3054, {...})
  8. end
  9.  
  10. while true do
  11.     local l = o.getEnergyStored() / o.getEnergyCapacity()
  12.     send_metric("reactor_energy/" .. name, "energy stored by reactor", "set", l)
  13.     print(l)
  14.     rs.setOutput(s, l < 0.8)
  15.     sleep(0.5)
  16. end
Add Comment
Please, Sign In to add comment