[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: First post: Hierarchal Data storage...
- From: virgil@... (Virgil Smith)
- Date: Thu, 11 Sep 2003 17:08:39 -0500
Title: First post: Hierarchal Data storage...
This is
very easy to implement into your own file format (I've done it myself in about 2
days work and I dove in slightly too quickly and had to rework my format
once (so it should be doable in less than a day of effort if you get serious
about it).
On a
side note I think that several implementations have been released
publicly (especially if all you need to support is tables, numbers, strings,
booleans, and functions). For my purposes I needed to add support for
storing user data's. I could have quickly hard coded for the one that I
needed for that first application, but it was very simple to generalize this so
that each type of user data can embed its own encoding into the file. This
requires that the userdatas have functions registered for reading/writing
(serializing/deserializing though in my case I "serialized" to a Lua table and a
special "blob" userdata rather than a string).
So just
code up a "write" function with a switch case based off of the lua_type of the
supplied argument, stamp down a short type indicator and any
number/string/boolean/nil you get, recurse for tables writing out key/value
pairs, apply some string.dump (or its C native equivalent) magic to get byte
code for functions, decide what you want to do with your user data's, and
probably write off thread objects as unsaveable (you could save them, but it'd
be a bit of work).
Alternatively you can try to dig up some precoded solutions (nice of
course if you wish to be interoperable with some other systems, but probably
more time consuming to dig up and integrate that to just code it
yourself).
I'm new to LUA, and my first Q is for storing
project config data...
Is it possible to store data readable from scripts,
and also in a unlimited hierarchal form?
E.g. (bad example)
Game
{
speech
{
volume 19
subtitles true
}
music
8
}
Dave Owens
............................................................................
Aged Codddddddddddeeeeerrrrrr!!!!!!!
.....Creaky Creaky.....
............................................................................
CLIMAX Solent
Somerville Office
North Promenade
Building
Gunwharf Quays
Portsmouth
PO1 3TT
(023) 9286
3675
......................................