如何从 LuaJava 中的 Lua 函数调用中获取值。
假设我有 calc.lua:
function foo(n) return n*2 end
我在Java中调用函数如下:
LuaState luaState;
this.luaState = LuaStateFactory.newLuaState();
this.luaState.openLibs();
this.luaState.LdoFile("calc.lua");
this.luaState.getGlobal("foo");
this.luaState.pushNumber(5.0);
int retcode=this.luaState.pcall(1, 1,0);
现在我必须在 LuaState 对象上调用什么来获得最后一个函数调用 foo(5) 的结果?
是否有示例显示 Java->Lua 调用以及调用的返回值?