Jump to content


Member Since 21 May 2015
Offline Last Active Aug 08 2020 03:34 PM

Topics I've Started

Question about textutils.serialize() and textutils.unserialize()

28 July 2020 - 06:05 PM


The scenerio:

I'm using CC1.5. I create a program that has nested tables in it. Something like:
t = {1,2,3,{true,false},"cat"}

I want to save this table for later use so I do this:

local file = fs.open(fn,"w")

I decide to turn off the game and have dinner. After a hearthy meal I turn on my computer again and start playing again.
My map loads up along with my CC program. It will get to the part in the code where it says:

local file = fs.open(fn,"r")
local data = file.readAll()
t = textutils.unserialize(data)

Will the values in the nested table be available for me? As far as I know (at least when I do a print(t) on my serialized table) only the table's reference is saved. Am I thinking it wrong? If not, how do I save the whole table so I can get back all the values?

Thanks in advance!