lua-users home
lua-l archive

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


On Sat, Apr 05, 2014 at 10:41:31PM +0200, Petite Abeille wrote:
> On Apr 5, 2014, at 10:09 PM, tonyp@acm.org wrote:
> 
> > I think the first place to look for required modules would be the (main)
> > script?s directory.  That also allows to override general libraries with
> > customized versions using the same name but placing them in the app?s
> > folder.
> 
> One relatively painless way to achieve this is to (1) look at where the main
> script was loaded from (e.g. debug.getinfo( 1, 'S' ).source) (2) Add that
> path to package.path (3) There is no step (3).

I guess that works (if you're willing to make use of the debug library), but
the main problem for me is that you've got to include the code to find the
source, parse it/alter to get the path (possibly handling different filesystem
types - Unix, case-insensitive Windows, etc.), in every Lua script.  By its
nature, you can't just pop it into a module you require().

Chris