textutils.unserialise

Converts a serialised string to a reassembled Lua value - the opposite of textutils.serialise. Returns nil if the unserialisation failed.

textutils.unserialise is implemented using load (source). It is loaded with an empty environment, therefore strings passed to textutils.unserialise cannot cause any harm to the computer. However, they can cause an infinite loop and cause the computer to crash for failing to yield!
ExampleDeserialising a serialised table
Prints a value of the given serialised table.
Code
<nowiki>
local serialised = "{ foo = \"bar\", fruit = \"apple\", colour = \"yellow\" }"
print(textutils.unserialise(serialised).fruit)
    </nowiki>
Output
<nowiki>
apple
</nowiki>

textutils.unserialise
Function
Syntax
textutils.unserialise(
  • serialisedValue : string
)

Returns any
API textutils
Source CC:Tweaked (source)
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.