lua-users home
lua-l archive

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



On 6 Oct 2006, at 07:16, Glenn Maynard wrote:

I'm planning on having Lua files scattered throughout a data tree,
alongside the assets they're related to.  I want to be able to load
other Lua files by both absolute and relative paths, relative to
the script loading it.

One way of doing this seems to be to pull the source path (of the
caller of whichever helper is being used to load) from debug
info.  (If it's not a @path, only allow absolute paths.)

This suffers from using the debug API for non-debug tasks, and also
requires being more careful about purging debug info.  I can't think
of any other way of doing this, though.  Access to the debug interface
would be hidden away in C, so I could still restrict access to "debug"
in Lua.

I have to say that the debug API approach you suggest seems fine. You know what you're doing. You could use luaL_where which is technically not in the "Debug API" if that makes you feel any happier.

drj