我试图在 android studio 中执行一个 lua 脚本,为此我使用了 http://www.luaj.org/luaj/3.0/README.html 中的 Luaj 库。 ? .
String script = "assets/hello.lua";
Globals globals = JsePlatform.standardGlobals();
LuaValue chunk = globals.loadfile(script);
m.setText(chunk.call( LuaValue.valueOf(script) ).tojstring());
我使用了这个,我的lua文件在 Assets 中,我只是将print(“hello”)放入我的lua文件中,所以我应该在我的 TextView 中得到hello结果,但我总是在我的 TextView 中得到“nil”有没有任何解决方案?
最佳答案
print("hello")
打印“hello”,然后返回 nil。从 chunk.call
获得的值是 Lua 代码返回的值,而不是打印的值。
关于java - 在java中执行lua脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57964206/