I've seen in some various IOS games Lua scripts being used for saving user settings, and data. I can't figure out how to do this myself, does anyone know of an open source project or example of how to achieve this?
Are people just re-writing the lua scripts programatically? Or is there some way in Lua to rewrite or save data in a lua script? I'm really confused on how this is achieved with lua. Please help me out!
Are people just re-writing the lua scripts programatically?
Yes, it's really very simple. You store your setting data or whatever in a table. You then write that table to a file using simple Lua code. The file you write is a Lua script that, when executed, returns the table.
So your script looks like this:
return
{
setting = true,
width = 640,
height = 480,
}
The code needed to write such serialization is not difficult to write (so long as you don't have tables referencing themselves, directly or indirectly). There are a variety of implementations of this.