I'm working on a program to run my Big Reactor (ala Direwolf20's recent CC program)
I started yesterday knowing very little about writing code and have managed to program the basic function which I wanted to start out with. I'm hoping to add more monitoring and adjustment functions later as I learn more, but this what I need to start off.
I want my reactor to shut off when the energy buffer is at 90% and restart when the buffer is down to 10%. My buffer is currently 10mil RF.
It works, once. If I run when the buffer is near full, it will shut down, and if I run the program when the buffer is low, it will start the reactor. It does not, however, shut the reactor back down once it is near full unless I rerun the program.
My question is what do I need to add in order to have this run in the background and continuously manage my reactor?
Here's my code:
component = require("component")
RF_BUFFER_MAX = 9000000
RF_BUFFER_MIN = 1000000
for _, reactor in pairs(REACTORS) do
if reactor.getEnergyStored() >= RF_BUFFER_MAX then
reactor.setActive(false)
print("Reactor is offline")
else if reactor.getEnergyStored() <=RF_BUFFER_MIN then
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Hello,
I'm working on a program to run my Big Reactor (ala Direwolf20's recent CC program)
I started yesterday knowing very little about writing code and have managed to program the basic function which I wanted to start out with. I'm hoping to add more monitoring and adjustment functions later as I learn more, but this what I need to start off.
I want my reactor to shut off when the energy buffer is at 90% and restart when the buffer is down to 10%. My buffer is currently 10mil RF.
It works, once. If I run when the buffer is near full, it will shut down, and if I run the program when the buffer is low, it will start the reactor. It does not, however, shut the reactor back down once it is near full unless I rerun the program.
My question is what do I need to add in order to have this run in the background and continuously manage my reactor?
Here's my code:
component = require("component")
RF_BUFFER_MAX = 9000000
RF_BUFFER_MIN = 1000000
for _, reactor in pairs(REACTORS) do
if reactor.getEnergyStored() >= RF_BUFFER_MAX then
reactor.setActive(false)
print("Reactor is offline")
else if reactor.getEnergyStored() <=RF_BUFFER_MIN then
reactor.setActive(true)
print("Reactor is online")
end
end
Thank you for any insight that you can give!
Link to post
Share on other sites