Skip to main content
gamedev.net
🔒 Locked

Saving Lua Variables

Started by timmy_isdaman 2 replies 1.4k views
Original Post
timmy_isdaman
timmy_isdaman
I'm looking for a way for my game engine to save the variables from the lua scripts it uses, so i can support savegames. Thanks in advance --timmy isdaman
Rob Loach
Rob Loach
If you're talking about saving the information to a file, you'll need to use something else then Lua because the Lua API doesn't do that. If you're looking for making a configuration file or something like that, you could looking into using INI files. I made a post about using INI files a while ago and Cygon made mention of a library that he created. I tried it out and it was pretty damn awesome. You can see the details in his reply.
Rob Loach [Website] [Projects] [
Sneftel
Sneftel
There's a few ways to do it. The most obvious (and unwieldy) way is to simply write out the values in some predefined order to a file, then read them back later. You could also use LuaPickle, although that was written for Lua 4.0 and may be outdated. You can use persistent tables, which automatically maintains a permanent version of the data contained in a table. Lastly, for more complex serialization/persistence, you can use my Pluto library.
timmy_isdaman
timmy_isdaman
ini files won't really work for what i'm doing.

Wow, pluto looks like exactly what i need. thanks a ton Sneftel.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.