Storage functions

So, my big question is: what can I store with the saveProjectData ? I’ve read that it only does numbers and strings (which would be disheartening, but not the end of the world), so, if that’s true, my next questions would be: are there technical limitations? What is holding it up? Is it a planned feature?

I’ve run across several Pure Lua ways to store files, I just don’t know if 1.) I can use them and 2.) if I can, how they will interact with Codea and the iPad storage. My intent is to write a 4X space strategy game in Codea, and the ability/lack of the ability to save more complex data is the only thing that’s causing me to hesitate.

Also: I love Codea. You guys did a wonderful job on it! I forgot to put that above :">

The project and global storage is actually implemented beneath it all as a plist - so ascii strings only (even numbers are simply stored as strings). if you need to store a binary, you’d need to encode it with base64 or such.

Having said that - they can be quite large. I’ve stored hundreds of k, and I’ll bet you can get megabytes into them.

You might be able to play shenanigans with the upcoming spritepack features to store larger binaries - but it would be a dirty hack. Which is sometimes the best kind. :slight_smile:

There has been talk about a “real” file I/O mechanism; or at least something with the same API (Apple is entirely unlikely to approve anything that can muck about in other App’s document space, but we might be able to get something sandboxed to just Codea’s Document space). I’m a big fan of the idea, but I know of no concrete plans to implement it.

Interesting. I’m thinking closer to a JSON file as a save game. Nothing too fancy (coordinate systems are pretty easy - especially with the way it looks like Codea deals with screen positioning - I’m still in the generation phase). The real question is, and the reason I need to store it as a table is the grouping of data. A group per system to be precise. Just text data, nothing binary.

Doable?

very much so - I’ve imported json4lua http://json.luaforge.net/ and used it successfully.

The only changes I had to make were commenting out the three “require” lines (they’re part of the core Codea stuff), and changing ‘module(“json”)’ to ‘local base = _G’ - so instead of “json.encode()” you’d just do “encode”.

You’re awesome! Thank you very much for the help!