←  Ask a Pro

ComputerCraft | Programmable Computers for Minecraft

»

Rednet messenger

phaleron's Photo phaleron 20 Jan 2013

Hey guys,

im searching a long time for "how do i get mutyple strings in one rednet.send()".
i found something by myselfs. turn 2 a variables into one string and then convert it back again with textutils.unserialize(), textutils.serialize() and tables.
but in dont have any clue how to do that!

please help me :)
Quote

stabby's Photo stabby 20 Jan 2013

You mean that you want to send for an example the varible A and the varible B at once?
Quote

phaleron's Photo phaleron 20 Jan 2013

View Poststabby, on 20 January 2013 - 06:29 AM, said:

You mean that you want to send for an example the varible A and the varible B at once?
yes indeed!
Quote

stabby's Photo stabby 20 Jan 2013

rednet.open("back") -- or whatever side your modem is on
local a = "Hey "
local b = "man"
rednet.send(id, a.. B)/>

Just use ".." after the varible to add another one (or string) For an example: (Id, "string".. "Hey".. varible.. "\n")
Quote

crazyguymgd's Photo crazyguymgd 20 Jan 2013

Then you have to parse the resulting string at the sender.
Quote

phaleron's Photo phaleron 20 Jan 2013

View Poststabby, on 20 January 2013 - 06:39 AM, said:

rednet.open("back") -- or whatever side your modem is on
local a = "Hey "
local b = "man"
rednet.send(id, a.. B)/>/>

Just use ".." after the varible to add another one (or string) For an example: (Id, "string".. "Hey".. varible.. "\n")
Thats perfect! thx!
Quote

phaleron's Photo phaleron 20 Jan 2013

View Postcrazyguymgd, on 20 January 2013 - 06:44 AM, said:

Then you have to parse the resulting string at the sender.
is parse like converting?
and how do i do it?
Quote

FF0084's Photo FF0084 20 Jan 2013

textutils.serialize

You can easily create a table, serialize it and send it as a single string. Then call textutils.unserialize function to get the table back.
Quote

W00dyR's Photo W00dyR 20 Jan 2013

View PostFF0084, on 20 January 2013 - 08:00 AM, said:

textutils.serialize

You can easily create a table, serialize it and send it as a single string. Then call textutils.unserialize function to get the table back.


Another function that is usefull for this kind of stuff, is

table.concat(<table name>, " ")

Adds up all the things in the table into a single line string
Quote

FF0084's Photo FF0084 20 Jan 2013

View PostW00dyR, on 20 January 2013 - 08:09 AM, said:

Another function that is usefull for this kind of stuff, is

table.concat(<table name>, " ")

Adds up all the things in the table into a single line string

I wish you good luck with separating the concatenated strings like this. It's pointless.
Quote

W00dyR's Photo W00dyR 20 Jan 2013

View PostFF0084, on 20 January 2013 - 08:16 AM, said:

I wish you good luck with separating the concatenated strings like this. It's pointless.

Im only talking about adding up all the things into a single string, not all the other stuff, couldve read what I said at least
Quote

FF0084's Photo FF0084 20 Jan 2013

View PostW00dyR, on 20 January 2013 - 08:18 AM, said:

View PostFF0084, on 20 January 2013 - 08:16 AM, said:

I wish you good luck with separating the concatenated strings like this. It's pointless.

Im only talking about adding up all the things into a single string, not all the other stuff, couldve read what I said at least

But this was not a problem sir. "couldve" read the original post mate.
Quote

W00dyR's Photo W00dyR 20 Jan 2013

View PostFF0084, on 20 January 2013 - 08:19 AM, said:

View PostW00dyR, on 20 January 2013 - 08:18 AM, said:

View PostFF0084, on 20 January 2013 - 08:16 AM, said:

I wish you good luck with separating the concatenated strings like this. It's pointless.

Im only talking about adding up all the things into a single string, not all the other stuff, couldve read what I said at least

But this was not a problem sir. "couldve" read the original post mate.

Couldve read the other posts and actually see what people are talking about.. Not here to argue so I'm not replying anymore.
Quote