Skip to content

how can i register a java function in lua ? #122

Answered by gudzpoz
skinkairewalker asked this question in Q&A
Discussion options

You must be logged in to vote

I don't think there is a universal way to do this. But pushing the corresponding object, setGlobal to assign it to a global variable and wrapping it up with a Lua function should work:

Function<String, String> f = (s) -> s + s;
L.push(f);
L.setGlobal("obj");
L.run("function f(s) obj:apply(s) end")

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by skinkairewalker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #110 on September 03, 2023 07:53.