Skip to content

Instantly share code, notes, and snippets.

@wendal
Created May 20, 2014 01:18
Show Gist options
  • Save wendal/87a2d821e7600f3e5494 to your computer and use it in GitHub Desktop.
Save wendal/87a2d821e7600f3e5494 to your computer and use it in GitHub Desktop.
luajava调用java对象方法及接收返回值
LuaState lua = LuaStateFactory.newLuaState();
lua.openLibs();
lua.pushJavaObject(new Thread() {
public void run() {
System.out.println("Lua Thread?");
}
});
lua.setGlobal("t");
int re = lua.LloadString("function f() t:run() return 123 end return f()");
System.out.println(re);
lua.pcall(0, 1, 0);
System.out.println("re="+re);
System.out.println(lua.getTop());
System.out.println(lua.getLuaObject(1).getNumber());
Lang.quiteSleep(2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment