문제

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;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top