有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

安卓 studio在java中执行lua脚本

我试图在安卓 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文件在资产中,我只是把打印(“你好”)放在我的lua文件中,所以我应该在我的文本视图中得到hello,但我在我的文本视图中总是得到“nil”,有什么解决方案吗


共 (1) 个答案

  1. # 1 楼答案

    print("hello")打印“hello”,然后返回nil。从chunk.call获得的值是Lua代码返回的值,而不是它打印的值