I recently started using computercraft and have run in to a problem. I've been try to print out messages in sequence with a rednet.receive() as the trigger and many varriables but can't get it to work. Hoping someone can help!
function log()
rednet.open("back")
message = rednet.receive(1)
local theatlog = { 65, 66, 62, 64, 63, 61 }
local nCurrentIndexPos = 0
while true do
sleep(1)
if rednet.receive() then
if message == theatlog[nCurrentIndexPos] then
nCurrentIndexPos = nCurrentIndexPos + 1
if nCurrentIndexPos == 1 then
print("Reactor 1 Stable")
elseif nCurrentIndexPos == 2 then
print("Reactor 2 Stable")
elseif nCurrentIndexPos == 3 then
print("Reactor 3 Stable")
elseif nCurrentIndexPos == 4 then
print("Reactor 4 Stable")
elseif nCurrentIndexPos == 5 then
print("Reactor 5 Stable")
elseif nCurrentIndexPos == 6 then
print("Breeder Reactor Stable")
end
if nCurrentIndexPos > 6 then
nCurrentIndexPos = 0
end
end
end
end
end
log()
That was the receiving terminal which would print the messages and the next is 1 of 6 sending information.
function heat()
rednet.open("left")
while true do
a = rs.getInput("front")
sleep(3)
if a == true then
rednet.send(60, "|Reactor 2 is critical") -- In the first program this is "66" because of it's computer ID, so really this line isn't really needed right?
else
rednet.send(60, "|Reactor 2 is offline/cold")
end
end
end
heat()
Please help, my reactors need it! :)/>/>