lua-users home
lua-l archive

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


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.

Any better approaches, or gotchas that I'm not thinking of?  I'd expect
this to be a common requirement for larger codebases; I should be able
to move around, rename and copy a directory without breaking internal
filename references.

-- 
Glenn Maynard