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

missing variable data

Started by ETHANATOR360, 06 August 2012 - 06:51 PM
ETHANATOR360 #1
Posted 06 August 2012 - 08:51 PM
client code:

rednet.open ("top")
rednet.broadcast ("iwannawatch")
while true do
local id, msg = rednet.receive()
if msg == "conf" then break
end
end
print "server authenticated testing streaming..."
sleep (2)
rednet.send (id, "stream.test")
while true do
local idc, test = rednet.receive()
if idc == id and test == test.correct then break
end
end
server code:

local side = "top"
rednet.open (side)
while true do
local id, msg = rednet.receive()
if msg == "iwannawatch" then break end
end
rednet.send (id,"conf")
print ("client authenticated waiting on stream test")
while true do
local idc, test = rednet.receive()
if idc == id and test == stream.test then break
else print ("wrong computer")
end
end
rednet.send ("test.correct")

in the second if statement of the server code it prints wrong computer i try printing id but it did nothing but leave an empty space were the value should be where is this variable data
OmegaVest #2
Posted 06 August 2012 - 09:01 PM
Quotations.
Strings need to be in quotes.
You are comparing a string to a non-existent variable. When you do, it counts the if as false, and sends it to the else.

I have no idea why the id value is coming up blank, but everything else is right (save I think rednet.send always needs an id, otherwise do broadcast). Try a tonumber, then term.write(numID). If it still has nothing. . . I don't know.
ETHANATOR360 #3
Posted 06 August 2012 - 09:22 PM
but idc isnt a string its a variable
OmegaVest #4
Posted 06 August 2012 - 11:28 PM

idc == id and test == stream.test

stream.test is NOT a variable, as you have it written. So, it needs quotes.


idc == id and test == "stream.test"
ETHANATOR360 #5
Posted 06 August 2012 - 11:36 PM
oh ok i thought you ment idc thanks :P/>/>