This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
currydevil's profile picture

BigReactor Control Rod Script Help

Started by currydevil, 27 May 2015 - 01:06 AM
currydevil #1
Posted 27 May 2015 - 03:06 AM
I am trying to make a script to actively set my control rod levels to the level of power currently in the reactor's internal buffer.

Here is what I have for now. It is currently producing an error "too long without yielding"

while true do

local reactor = peripheral.wrap("BigReactors-Reactor_0")
local power = ((reactor.getEnergyStored() / 10000000) * 100)

if reactor.getActive() == true
then
reactor.setAllControlRodLevels(power)
end

end

sleep(5)

I know this is not quite right. I had someone write a program that did the same thing once, but I cannot remember how he wrote it, and this is my first time really playing with computers myself.
Bomb Bloke #2
Posted 27 May 2015 - 03:32 AM
Move your sleep(5) call into your while loop, just above that last "end", say.

You'll probably also want to set your rods to 100 - power.
currydevil #3
Posted 27 May 2015 - 06:06 AM
Thanks, that worked. And I tried using "100 - power", but that just set the rods to 0% when the buffer is full. Quite the opposite of what I wanted.
Bomb Bloke #4
Posted 27 May 2015 - 08:03 AM
I've gotta ask - why would you want the reactor producing energy flat-out when it's already full, but not at all when it's empty?
Lyqyd #5
Posted 27 May 2015 - 02:38 PM
100% rod insertion entirely prevents energy production, as in real reactors.
Bomb Bloke #6
Posted 28 May 2015 - 01:18 AM
Ah, I was assuming the function name referred to extension - silly me, I guess.
currydevil #7
Posted 28 May 2015 - 01:25 AM
Pretty much, this sets the rod insertion % to match the % of the buffer. So, if my buffer is 80% full, the rods will be set to 80% insertion. The rods will be inserted less and less as the energy in the buffer gets lower.