Possible to save data tables instead of strings and property lists?

As far as I can tell, you can only save out strings of text to files, or, by using CrawlSpaceLib you can save properties like this:

local data = {};  
data.lives = 5;  
data.health = 75;  
Save(data);  

But I have situations where I need to save a table of data. For example, which of 10 levels are “unlocked”. So I have a table called lockedStatus which would look like this:

{false, false, false, true, true, true, true, true, true, true}

meaning that the first 3 levels are unlocked.

So when the user quits the app and comes back, I need to save the table. Is there a better way to do it than converting it to a string and then reconstructing the table from the string in the text file upon relaunch? [import]uid: 52127 topic_id: 12700 reply_id: 312700[/import]

in c++ you would do something like overwriting the stream >> operator.

but in lua you can’t. so you can do two things

one what you describe by saving the contents of the table in string format, or saving an integer 1 for true 0 for false.

c. [import]uid: 24 topic_id: 12700 reply_id: 46542[/import]

as what Carlos said, for Lua, you can try two things, you can use the PropertyBag and save

Level1 =
Level2 =

and so on… or

LevelData = "01110010101"
where each each character corresponds to a level number. Which you can then access easily from Lua.

Plus for levels, generally you cannot skip levels and you have to unlock a previous level before you can unlock the next one. So you can just save LevelUnlocked = and keep updating it when you go to the next one.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 12700 reply_id: 46555[/import]