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

Passing variables through rednet

Started by isolatedvirus, 20 August 2014 - 03:34 AM
isolatedvirus #1
Posted 20 August 2014 - 05:34 AM
I am attempting to send a rednet message to a remote computer, and have that computer display the information. To facilitate this, the message contains the variable that i want the remote computer to set the value as. I'm new to LUA, and cant seem to figure out how to splat these variables from the string received. Any help would be greatly appreciated!

Sender:
rp = 1
rednet.broadcast("RP,"..rp,"myprotocol")

Receiver:

id, msg, proto = rednet.receive("myprotocol")
rvar, rval = msg
print("rval")

I'm receiving the error message: "Attempt to concatenate string and nil"

Thanks in advance!
Dragon53535 #2
Posted 20 August 2014 - 08:29 AM
As far as i understand that would be impossible unless there's a tovariable() function that would convert the string passed from the rednet receive and turn it into a variable that you could store data with.
Bomb Bloke #3
Posted 20 August 2014 - 10:03 AM
There are a lot of ways you could get the same effect, though - in particular, tables would likely be the simplest.
isolatedvirus #4
Posted 20 August 2014 - 11:44 PM
There are a lot of ways you could get the same effect, though - in particular, tables would likely be the simplest.

this looks like the simplest and most effective way to pass the data i want over rednet. Thanks!