I am aware of this method:
How can I add functions to _G that run java code using Luaj?
But that link lets you add functions such as math.abs(...)
. I just want to add functions without libraries or having to use require
, you can just use myfunction()
right out of the box.
How do I do this?
I found the answer in the LuaJ source:
public LuaValue call(LuaValue modname, LuaValue env)
{
globals = env.checkglobals();
env.set("assert", new _assert());
env.set("collectgarbage", new collectgarbage());
env.set("dofile", new dofile());
....
return env;
}