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

Numbers...

Started by datdenkikniet, 16 December 2013 - 07:30 AM
datdenkikniet #1
Posted 16 December 2013 - 08:30 AM
So, I have this code already (I am trying to make my own chat program) but for some reason, the rednet.send() on line 26 won't work, because it requires a number. I thought I could do this by using tonumber(), but it doesn't work.
I would be very pleased if you could tell me how I can do this.
Thanks in advance
Datdenkikniet (Jona)
Ajt86 #2
Posted 16 December 2013 - 11:15 AM
To use rednet.send, you need to provide two arguments, the channel and the message. All computers listening to that channel can receive the message. Here's an example:

id = 29
msg = "Hello, Computer #"..id
rednet.send(id, msg)
Edited on 16 December 2013 - 01:22 PM
Csstform #3
Posted 16 December 2013 - 01:17 PM
To use rednet.send, you need to provide two arguments, the channel and the message. All computers listening to that channel can receive the message. Here's an example:

id = 29
msg = "Hello, Computer #29"
rednet.send(29, msg)
I believe you mean

rednet.send(id, msg)
Ajt86 #4
Posted 16 December 2013 - 02:22 PM
To use rednet.send, you need to provide two arguments, the channel and the message. All computers listening to that channel can receive the message. Here's an example:

id = 29
msg = "Hello, Computer #29"
rednet.send(29, msg)
I believe you mean

rednet.send(id, msg)
I'll edit the post
datdenkikniet #5
Posted 16 December 2013 - 02:24 PM
Yes, but the string from the arguments used in chat <ID> where <ID> is the argument, should be converted in to an int, but it wont!
Lyqyd #6
Posted 16 December 2013 - 02:45 PM
Lua is one-indexed, not zero-indexed. Change line 26 to use both tonumber and the correct indexing:


rednet.send(tonumber(chatID[1]), "authentication!!!!")
datdenkikniet #7
Posted 16 December 2013 - 03:26 PM
Lua is one-indexed, not zero-indexed. Change line 26 to use both tonumber and the correct indexing:


rednet.send(tonumber(chatID[1]), "authentication!!!!")
Aha, thank you very very much Lyqyd