If I were to do
CoerceJavaToLua (new Vector2(3, 5));
What would it return, and how do I access the values in lua? Do I pass the returned value as such:
globals.load(CoerceJavaToLua(new Vector2(3, 5)));
It converts a Java value into a LuaValue that include metatables making it convenient to manipulate within lua scripts.
Instead of loading, try setting a coerced value in the globals, then execute a script that uses the value:
Globals globals = JsePlatform.standardGlobals();
globals.set("image", CoerceJavaToLua.coerce(
new BufferedImage(30,40,BufferedImage.TYPE_INT_RGB)));
LuaValue chunk = globals.load(
"print(image:getWidth(), image:getHeight());");
chunk.call();
which outputs:
30 40
Any public field or method on image is accessible, and return values are coerced, so most operations in Java can be performed in lua at that point.
See the swing example to see an elaborate example including callback handling.