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

Getting the senderID via Rednet

Started by TheLuke, 11 June 2014 - 04:37 PM
TheLuke #1
Posted 11 June 2014 - 06:37 PM
Heyho everyone,

i got a litte question by using rednet. It is about a kind of security. I would like to check the senderid bevor doing something else, but it is not working. Google and the wiki didnt help so far.

My Code:

Computer 1 (Transmitter)

rednet.open("right")
rednet.send(5, "cauf")
rednet.close("right")

Computer 2 (Receiver)

[...]
rednet.open("bottom")
local senderID, message, protocol = rednet.receive()
if senderID == 1 then
-- Do stuff here.
else
print("Sender not allowed!")
end
[...]

I tryed to check which computer has send the "message"..

I'm looking for some help and sorry for my bad english - not well trained jet :(/>
MKlegoman357 #2
Posted 11 June 2014 - 06:50 PM
Your code looks fine to me. Check if you are sending to the correct computer, check the IDs of both computers by running 'id' program:


CraftOS 1.6
> id

EDIT: also, what do you mean by 'not working'? What's happening?
Edited on 11 June 2014 - 04:52 PM
TheLuke #3
Posted 11 June 2014 - 06:52 PM
Thanks for your reply, but i'v checked that bevor and i tryed in another "clear" world as well - same result :(/>

EDIT
I have made a spelling mistake in Line 3. Of course it must be: senderId and not senderID ._.

Thanks for you help :)/>
Edited on 11 June 2014 - 05:16 PM