Open JuKu opened 6 years ago
I already have found the solution: I have to use class Table instead of an array:
@Test
public void testExecGlobalFunc () throws ScriptLoadException, CallException {
GameTime time = GameTime.getInstance();
time.setTime(System.currentTimeMillis());
LuaScriptEngine engine = new LuaScriptEngine();
engine.compile("add", "function add (a)\n" +
" local sum = 0\n" +
" for i,v in ipairs(a) do\n" +
" print(v);" +
" sum = sum + v\n" +
" end\n" +
" return sum\n" +
" end");
engine.execScript("add");
engine.printEnvDebug();
Table table = new DefaultTable();
table.rawset(1l, new Long(1));
table.rawset(2l, new Long(2));
table.rawset(3l, new Long(3));
assertEquals(6l, engine.execFunc("add", table));
}
I get this exception:
What does this exception means?
Source code:
Test method which throws this exception: