How to Load and Call a Function from a Lua File #207
Replies: 2 comments
-
find the problem try (Lua L = new LuaJit()) {
L.openLibraries();
ClassPathLoader classPathLoader = new ClassPathLoader();
L.setExternalLoader(classPathLoader);
Buffer buffer = classPathLoader.load("luajava/simpleLuaFile", null);
L.run(buffer, "luajava/simpleLuaFile");
L.getGlobal("test");
LuaValue function = L.get();
funcion.call();
System.out.println(function.type());
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yes, (By the way, you can save a few lines of code with the following: try (Lua L = new LuaJit()) {
L.openLibraries();
L.setExternalLoader(new ClassPathLoader());
L.run("require('luajava.simpleLuaFile')"); // I guess I will add a Lua.require to facilitate usages like this
LuaValue function = L.get("test");
funcion.call();
System.out.println(function.type());
} ) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I am working on porting a project that depends on the oldest version of luajava (www.keplerproject.org/luajava/) to the current version of luajava. I have two issues:
The Lua file source code is as follows (from the luajava project test case):
In the oldest version of Kepler luajava, I only needed to call the following code:
In the current version of luajava, I tried the following code:
this just return NIL
please help
Beta Was this translation helpful? Give feedback.
All reactions