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

big reacter automation code

Started by jrradi, 28 November 2014 - 08:29 PM
jrradi #1
Posted 28 November 2014 - 09:29 PM
hi
i need help with this code
i just want the the code to turn on the reacter if the energy is low and stop when its hits 7mil rf then sleep for 3600 sec because i have 2bil rf bank capacitors
here is the code i made

while true do
  local reactor = peripheral.wrap("BigReactors-Reactor_3")
  local low = 2000
  local high = 7000000

  if reacter.getEnergyStored() <= low then
	reactor.setActive(true)
  end

  if reacter.getEnergyStored() >= high then
	reactor.setActive(false)
  end

  sleep(5)
end
when i change the 5 sec to 3600 sec it just turn the reactor on then sleep for 3600
i want it to turn it off the reactor after it reach 7mil rf then sleep because 2bil rf will take 2-3 hours before it drains


or if we can make the computer check the bank capacitor 2bil rf capacity 1- if under 25% activate reactor 2-if 99% turn off reactor
i don't know how to do that
appreciate your help.
ShadowDisruptor #2
Posted 29 November 2014 - 04:55 PM
You name your reactor variable 'reactor,' but when you have if statements, you have 'reacter.' That will cause errors right away. Also, you should call all of your variables outside the loop. No reason to reset them since you're not changing anything. After you fix those tag me if you still have issues.
KingofGamesYami #3
Posted 29 November 2014 - 05:46 PM
You can't "call" a variable, only functions. And yes, generally you want to define as many variables as possible before the loop. This should do what you want, if I understand you correctly.


local reactor = peripheral.wrap( "BigReactors-Reactor_3" )
local low, high, time = 2000, 7000000, 5

while true do
  local energy = reactor.getEnergyStored()
  if energy <= low then
	reactor.setActive( true )
	time = 5
  elseif energy >= high then
	reactor.setActive( false )
	time = 3600
  end
  sleep( time )
end
Edited on 29 November 2014 - 04:46 PM
jrradi #4
Posted 29 November 2014 - 09:01 PM
thanks guys that was awesome