Closed Trivaxy closed 3 months ago
You may use Java method modules for that.
I see. Is it possible to alias the module name to something simpler for the users?
i.e require("world")
instead of require("xyz.trivaxy.modules.MyModule.open")
LuaJava does not provide a builtin way to do this. But you can of course rewrite the require
function as you wish:
local oldRequire = require
local mapping = {
shortname = "xyz.trivaxy.modules.MyModule.open",
}
function require(name)
return oldRequire(mapping[name] or name)
end
Yeah, that's a good way to do it. Thanks.
I'm working on integrating LuaJava to one of my projects. To keep things clean, a lot of the functionality implemented on the Java side is (meant to be) exposed to the Lua side in the form of custom modules, e.g
I've seen
setExternalLoader
andloadExternal
, but those don't seem to be what I need as these modules are entirely implemented on the Java side. Any advice?