1326 posts
Location
Error 404: Could not find.
Posted 29 May 2014 - 12:36 AM
What is the term.serialize() and term.unserialize() good for and what do they do?
1281 posts
Posted 29 May 2014 - 12:43 AM
term.serialize, is that a 1.6 thing i didn't catch, or do you mean textutils.serialize?
textutils.serialize is used to convert a table to a string, unserialize converts it back.
Edited on 28 May 2014 - 10:43 PM
8543 posts
Posted 29 May 2014 - 12:43 AM
Where are you seeing term.serialize? I only know of textutils.serialize and textutils.unserialize, which are used for turning a table in a string representing the table and vice-versa.
1326 posts
Location
Error 404: Could not find.
Posted 29 May 2014 - 12:44 AM
lol my bad textutils.serialize()
[EDIT] Im used to term than textutils
Edited on 28 May 2014 - 10:45 PM
1852 posts
Location
Sweden
Posted 29 May 2014 - 07:11 PM
textutils.serialize converts a table into a string
It's good when saving a table to a file
local t = { foo = "bar" }
local f = fs.open( "foo-bar", "w" )
f.writeLine( textutils.serialize( t ) )
f.close()
or sending it over rednet
local t = { foo = "bar" }
rednet.send( 101, textutils.serialize( t )
textutils.unserialize converts it back
it's good when loading a serialized table from a file or getting a serialized table over rednet
local f = fs.open( "foo-bar", "r" )
local t = textutils.unserialize( f.readAll() )
f.close()
local id, msg = rednet.receive()
local t = textutils.unserialize( msg )
1326 posts
Location
Error 404: Could not find.
Posted 02 June 2014 - 11:08 PM
Thanks, That helps a lot.