• From: Ivan Kolev <ikolev@...>
• Date: Fri, 23 Apr 2004 14:06:16 +0200

Since loadlib is already there, I don't think it would hurt a lot if
there was a requirelib function which would do for loadlib the same that
require does for loadfile (i.e. use LUA_PATH to search for the module).
At least for the symmetry. Or maybe even have require do all the work.
Here's the function I'm using now:

else
end
end

if not importFunc then  -- try a .lua module first
local res, mod = pcall( require, module )
if res then return mod end
-- a .lua module was not found, try a DLL with luaLM_import
importFunc = "luaLM_import"
end

local path = LUA_PATH or os.getenv "LUA_PATH"
for m in string.gfind( path, "[^;]+" ) do
m = string.gsub( m, "%?", module )  -- replace ? with module
m = loadlib( m, importFunc )
if m then
m = m()
return m
end
end
return nil
end

core). Now all I have to do is set the environment variable LUA_PATH to

?;?.lua;\path\to\LuaTools\?.lua;\path\to\LuaTools\?.dll

and then in the beginning of aTool\aTool.lua:

local utils = require "utils"
local subModule = utils.loadModule( "aTool/subModule" )

This would load both a Lua module from aTool\subModule.lua, or a DLL
module from aTool\subModule.dll

Ivan

Jamie Webb wrote:


On Friday 23 April 2004 11:28, Ivan Kolev wrote:


Something definitely must be added to Lua or the auxiliary libraries to




That sort of stuff is rather OS and application dependent. The core Lua distribution is intended to be as agnostic as possible. The sort of thing you're looking for is implemented by standalone distributions such as LuaCheia.

-- Jamie Webb