gudzpoz / luajava

Lua for Java on Windows, Mac OS X, Linux, Android. 5.1, 5.2, 5.3, 5.4, LuaJ or LuaJIT.
https://gudzpoz.github.io/luajava/
Other
154 stars 21 forks source link

[QUESTION]How to Call a Lua Function from Java? #24

Closed leasses closed 2 years ago

leasses commented 2 years ago

In the orgin luajava, there is a class LuaFunction, and I can call it by its method _call. But I did't find this in your luajava. Maybe I missed, could you please tell me how to do? Thanks!

And, thanks so much for you contribution of this project. I am sure this is the best luajava in all of I knows. ❤

gudzpoz commented 2 years ago

You may use the new LuaValue API.

L.run("return function(str) print('Hello ' .. str) end");
try (LuaValue function = L.get()) {
    function.call("World");
}
leasses commented 2 years ago

Thanks!