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

[SOLVED] Table via Rednet

Started by Hayden_Almeida, 10 February 2015 - 05:35 PM
Hayden_Almeida #1
Posted 10 February 2015 - 06:35 PM
Hello guys.
I have 2 PCs, 1 is the Client, and the other is the SERVER.


In the Client i have:

local T = {}
T[0] = ler2
T[1] = ler3
local Table = textutils.serialize(T)
rednet.send(servidorID, Table)

In the SERVER i have:


local id, msg = rednet.receive(4)
print("Msg:"..msg)
print("MSG1:"..msg[0])
print("MSG2:"..msg[1])

Only the print("MSG"..msg) IS PRINTED on the screen
Like this:

{
"123",
[0] = "Hayden",
}

My question is: how can i get only the First line ( [0] ) or the second line ( [1] ). Explaining: how can i get the separete values of the Table?
Edited on 10 February 2015 - 06:41 PM
mistamadd001 #2
Posted 10 February 2015 - 07:05 PM
you need to unserialize the message at the receiving end.


local id, msg = rednet.receive()
local msg = textutils.unserialize(msg)
print('Msg: '..msg[0])
print('Msg: '..msg[1])
--etc
Hayden_Almeida #3
Posted 10 February 2015 - 07:41 PM
you need to unserialize the message at the receiving end.


local id, msg = rednet.receive()
local msg = textutils.unserialize(msg)
print('Msg: '..msg[0])
print('Msg: '..msg[1])
--etc

THanks.
lincore #4
Posted 10 February 2015 - 09:15 PM
You can send tables with rednet.send directly for quite a few versions now. Unless you are using an old version of mc serialization is not necessary.