lua-users home
lua-l archive

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


2011/1/21 Gustavo de Sá Carvalho Honorato <gustavohonorato@gmail.com>:
> Hi,
> how can I use require function passing the file path relative to the file
> that is calling the require function, as we do with #include in C?

Refer to the recent thread "How to get the directory of the current
executed file?"
http://article.gmane.org/gmane.comp.lang.lua.general/73754

As mentioned in that thread, debug.getinfo(1, "S").source:sub(2) will
give you the name of file being executed - you just need to split out
the dirname and then edit your package.path appropriately.

Alex