Advertisement
Samotage820

cc reactor manager

Aug 2nd, 2021 (edited)
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. local reactor = peripheral.wrap("back")
  2. local max_buf = 25646000
  3. local max_desired_buf = .90 * max_buf
  4. local min_desired_buf = .20 * max_buf
  5. local cur_buf
  6. rednet.open("right")
  7.  
  8. local function status(buffer)
  9.     local buf_state = string.format("Reactor buffer %.2f%% full", buffer / max_buf * 100)
  10.     if reactor.getActive() then
  11.         return "ON:  " .. buf_state
  12.     else
  13.         return "OFF: " .. buf_state
  14.     end
  15. end
  16.  
  17. while true do
  18.     cur_buf = reactor.getEnergyStored()
  19.     if cur_buf < min_desired_buf then
  20.         reactor.setActive(true)
  21.     elseif cur_buf > max_desired_buf then
  22.         reactor.setActive(false)
  23.     end
  24.     print(status(cur_buf))
  25.     rednet.send(4, status(cur_buf))
  26.     os.sleep(5)
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement