I am trying to write some code to control them in sequence, increasing power production from the bottom up. The current code that I have will follow
Code for the bottom (1st) reactor
local reactorNum = 1
local reactor = peripheral.wrap('left')
local computer = peripheral.wrap('top')
local active = 0
local energy = 5000000
local allRods = 1600
local increment = 5
local rodMax = 1600 - ((reactorNum-1)*100)
while active == 0 do
active = reactor.getConnected
if active == 0 then
print('Reactor not connected')
end
os.sleep(1)
end
print('Reactor connected')
if reactor.getActive == 0 then
reactor.setActive(1)
end
while true do
energy = reactor.getEnergyStored
if energy < 1000 and allRods > 0 then
allRods = allRods - increment
elseif energy > 9500000 and allRods < 1600 then
allRods = allrods + increment
end
if rodMax - allRods > 100 then
reactor.setAllControlRodLevels(0)
print('Control rod level = 0')
computer.transmit(1,1,allrods-100)
else
reactor.setAllControlRodLevels(100-(rodMax-allRods))
print('Control rod level = '..(rodMax-allRods))
computer.transmit(1,1,rodMax-100)
end
os.sleep(1)
end
Code for reactors 2-15
local reactorNum = CHANGE REACTOR NUMBER
local reactor = peripheral.wrap('left')
local computer = peripheral.wrap('top')
local modem = peripheral.wrap('bottom')
local active = 0
local rodMax = 1600 - ((reactorNum-1)*100)
local allRods = rodMax
modem.open(REACTOR NUMBER MINUS 1 HERE)
while active == 0 do
active = reactor.getConnected
if active == 0 then
print('Reactor not connected')
end
os.sleep(1)
end
print('Reactor connected')
if reactor.getActive == 0 then
reactor.setActive(1)
end
while true do
local message = os.pullEvent('modem_message')
allRods = message
if rodMax - allRods > 100 then
reactor.setAllControlRodLevels(0)
print('Control rod level = 0')
computer.transmit(reactorNum,reactorNum,allrods-100)
else
reactor.setAllControlRodLevels(100-(rodMax-allRods))
print('Control rod level = '..(rodMax-allRods))
computer.transmit(reactorNum,reactorNum,rodMax-100)
end
end
Code for the top (16th) reactor
local reactorNum = 16
local reactor = peripheral.wrap('left')
local modem = peripheral.wrap('bottom')
local active = 0
local rodMax = 1600 - ((reactorNum-1)*100)
local allRods = rodMax
modem.open(15)
while active == 0 do
active = reactor.getConnected
if active == 0 then
print('Reactor not connected')
end
os.sleep(1)
end
print('Reactor connected')
if reactor.getActive == 0 then
reactor.setActive(1)
end
while true do
local message = os.pullEvent('modem_message')
allRods = message
if rodMax - allRods > 100 then
reactor.setAllControlRodLevels(0)
print('Control rod level = 0')
else
reactor.setAllControlRodLevels(100-(rodMax-allRods))
print('Control rod level = '..(rodMax-allRods))
end
end
Currently, I am trying to debug the 1st reactor's code. All other code seems to run fine. This is the error I get: http://i.imgur.com/1MmwSQs.png Any Ideas on what Im doing wrong? Also, is there anything else messed up with my code?