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

Rednet and Tables

Started by kylergs, 10 November 2012 - 06:11 AM
kylergs #1
Posted 10 November 2012 - 07:11 AM
Is it possible to send a table across rednet, I did a little testing but to no avail. If not, is there another efficient way of sending lots of data over rednet (At the moment I'm thinking of joining strings with a semi-colon and separating on the other computer)
jag #2
Posted 10 November 2012 - 07:31 AM
Lookup textutils.serialize() and textutils.unserialize()!
But basically this is how it works:

--(( Sender ))--
local sendingTable = {
  -- Just some random variables
  password = 1234,
  myName = "kylergs",
  binary = 01001011
}

rednet.send(123, text.serialize(sendingTable))

--(( Receiver ))--
local id,msg = rednet.receive()
local receivedTable = textutils.unserialize(msg)

print(receivedTable.password)
-- Will print 1234
kylergs #3
Posted 18 November 2012 - 08:38 AM
Thanks, that helps a lot.