Difference between revisions of "Textutils.serialize"
From ComputerCraft Wiki
m (Moved to CAT:APIFunctions) |
|||
| Line 18: | Line 18: | ||
}} | }} | ||
}} | }} | ||
| + | |||
| + | [[Category:API_Functions]] | ||
Revision as of 18:41, 28 November 2012
| Converts the object to a string that can be saved in a file or sent over rednet and then converted back into a copy of the object later, using unserialize. Nested structures are supported, but tables with circular graphs will be detected and raise an error. | |
| Syntax | textutils.serialize(anything) |
| Returns | a string representing the object |
| Part of | ComputerCraft |
| API | textutils |
Examples
| Sends a table over rednet, demonstrates object recovery | |
| Code |
myThing={name="Test", n=2}
sThing=textutils.serialize(myThing)
rednet.send(receiverID, sThing) -- assuming you have rednet open and receiverID has a useful value
myCopy=textutils.unserialize(sThing)
print(myCopy.name)
|
| Output | Test |