lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 02 Mar 2010 14:48:10 +0100
Peter Cawley <> wrote:

> On Tue, Mar 2, 2010 at 1:43 PM, Nicolas <> wrote:
> > My game currently handles its savefiles as a serialization of the running
> > objects, since some objects can have functions dynamically attached to
> > them it needs string.dump to serialize them and later reload them.
> The alternative approach to serialising a function is to use the debug
> API to get the filename and line number where it was defined, then
> load said file, pull out the actual code, and thus save the source
> code rather than bytecode.

But that does not tell me from which line to which line to take.
It does not even work if the function was defined inline somewhere like that:

	foo = function()
	pop = "pup",

There is no way to extract the currect code.
(Also this relies on debug.* instead of standard libs)

Or did I misunderstand you ?

PS: Sorry this is a tad out of subject for the thread :/