I'm struggling to get a program I found on here working (http://www.computerc...onitor-program/).
For some reason, in the receiver, the table exists but the subcomponents are always nil. I consistently get an error saying ".temp:28: attempt to index ? (a nil value) when checking mes.active.
The code for the receiver:
-- program to print valuable information
-- about reactor
rednet.open("right")
local mon = peripheral.wrap("left")
local protocol = 1
term.redirect(mon)
term.clear()
while true do
local id, mes, pro = rednet.receive(protocol, 5)
term.redirect(mon)
term.clear()
sleep(0.5)
term.setCursorPos(1,1)
mon.setTextScale(0.5)
if mes == false then
write("STATUS: ")
mon.setBackgroundColor(colors.red)
write("ERROR")
mon.setBackgroundColor(colors.black)
print()
print()
print("Something is wrong with program or reactor setup")
print("Hold Ctrl+T to terminate program")
else
write( "STATUS: ")
if mes.active == true then
mon.setBackgroundColour(colors.lime)
write("ACTIVE")
elseif mes.active == false then
mon.setBackgroundColour(colors.yellow)
write("NOT ACTIVE")
end
mon.setBackgroundColor(colors.black)
print()
print()
print("Energy Production: " .. math.floor(mes.energyOutput,0) .. " EU/t")
print("Tank Info; " .. mes.tankInfo .. " RF")
print()
print("Temperature: " .. mes.reactorTemp .. " C")
print("Max Temperature: " .. mes.reactorMaxTemp .. " C")
end
sleep(0.1)
end
code for the sender:
-- program to monitor reactor health
rednet.open("left")
local reactor = peripheral.wrap("right")
local protocal = 1
while true do
works = reactor.isValid()
if works == false then
rednet.broadcast(works, protocol)
sleep(0.1)
else
--ractive = reactor.isActive()
--rheat = reactor.getHeat()
--rmheat = reactor.getMaxHeat()
--reuout = reactor.getEUOutput()
--rtank = reactor.getTankInfo()
local mytable =
{
active = reactor.isActive(),
reactorTemp = reactor.getHeat(),
reactorMaxTemp = reactor.getMaxHeat(),
energyOutput = reactor.EUOutput
--tankInfo = rtank
}
rednet.broadcast(mytable,protocol)
sleep(0.1)
print(mytable.active)
print(mytable.reactorTemp)
print(mytable.reactorMaxTemp)
print(mytable.energyOutput)
print(mytable.tankInfo)
end
end