lua-users home
lua-l archive

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


haha thanks,

I'm hoping to use this for my game engine editor, which uses lua interface.

I think what i'll end up doing is to construct a data structure that matches the hierarchy of modules in the directory path, and then when the user wants to use a particular module in the GUI it just adds the strings together and calls require, that way im not over including things.



On Mon, Feb 8, 2010 at 1:28 PM, Patrick Donnelly <batrick@batbytes.com> wrote:
On Mon, Feb 8, 2010 at 3:25 PM, Joe Andresen <joe.andresen@gmail.com> wrote:
> is it possible to require all give modules in a path without knowing their
> names?
>
> Will this work with subdirectories of that path as well? or does that have
> to be included in package.path?

Lua simply appends the module name to each path and then tries to open
the file. It has no concept of a directory so it cannot iterate over
the files in a directory for modules to load.

On the other hand, you can construct LUA_INIT so that it requires all
modules in a directory with some fancy bash code (an exercise left to
the reader).

--
- Patrick Donnelly