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

[solved] rednet.send() returning an error

Started by Rsstn, 05 August 2012 - 05:43 PM
Rsstn #1
Posted 05 August 2012 - 07:43 PM
I'm using the code below as a basic start for a program which will return the id of a computer when it receives a message from the host computer (with an ID of 6).


rednet.open("right")
local id, msg = rednet.receive()
if id == 6 then
one = os.getComputerID()
rednet.send(6, one)
end

The idea is that the host computer can receive the id of the receiving computer for use in another program.
Only problem is, I'm getting the 'rednet:350: string expected' error, and can't work out what is wrong.
I've looked at any other examples of the get ID command and rednet sending commands, and can't see any difference to my code.
Even after around 2 hours of experimentation, I've had no luck. So…

Any ideas as to what is wrong here?
Thanks in advance, Rsstn.
Zalerinian #2
Posted 05 August 2012 - 07:52 PM
I'm using the code below as a basic start for a program which will return the id of a computer when it receives a message from the host computer (with an ID of 6).


rednet.open("right")
local id, msg = rednet.receive()
if id == 6 then
one = os.getComputerID()
rednet.send(6, one)
end

The idea is that the host computer can receive the id of the receiving computer for use in another program.
Only problem is, I'm getting the 'rednet:350: string expected' error, and can't work out what is wrong.
I've looked at any other examples of the get ID command and rednet sending commands, and can't see any difference to my code.
Even after around 2 hours of experimentation, I've had no luck. So…

Any ideas as to what is wrong here?
Thanks in advance, Rsstn.

Thats a nice simple code, but you error is on line 4.

This

one = os.getComputerID()

should be this

one = os.computerID()

You can find it on the wiki
ElvishJerricco #3
Posted 05 August 2012 - 07:52 PM
The message being sent through rednet has to be a string. It can't be a number. So do something simple like one = "" .. os.getComputerID()
Lyqyd #4
Posted 05 August 2012 - 07:55 PM

one = tostring(os.computerID())
Rsstn #5
Posted 05 August 2012 - 07:56 PM
The message being sent through rednet has to be a string. It can't be a number. So do something simple like one = "" .. os.getComputerID()

Thanks, this worked. +1!