[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: pseudo self modifying code?
- From: Ben Kelly <ranavin@...>
- Date: Tue, 1 Feb 2011 19:13:12 -0500
On Tuesday 01 February 2011 13:56:37 Patrick Mc(avery wrote:
> Rather then using a DB or tables & Pluto I was thinking about storing
> information in Lua scripts that would then be executed by other Lua
> scripts via dofile. I was thinking that the executing script could also
> modify the storage script for persistence. This set up would also allow
> me to hand edit the storage script later, bypassing the main limitation
> I see with a DB or a serialization library like Pluto.
>
> Is there a proper name for this? Is there any code out there that I
> could use as a template?
>
> Thanks for reading-Patrick
This is a fairly common usage; lua code is easy to generate, easy for humans
to read, and easy to load, so it's a good choice for a human-and-machine-
writeable config file format (and similar uses). You can see real-world examples
of this, in for example, Supreme Commander (which uses machine-edited lua
scripts for game configuration, save files, and maps, among other things).
The information on table serialization in the wiki[1] might be of interest to
you; among other things it discusses serializing a table to Lua source. Once
you have that you can just store the info in a table at runtime, load it from
disk at startup with dofile and save the updated version at shutdown with your
serializer of choice.
Ben Kelly
[1] http://lua-users.org/wiki/TableSerialization