Excute lua script in java

227 views Asked by At

Iam trying to excute an lua script in android studio for this i used Luaj library from http://www.luaj.org/luaj/3.0/README.html? .

String script = "assets/hello.lua";
    Globals globals = JsePlatform.standardGlobals();
    LuaValue chunk = globals.loadfile(script);
    m.setText(chunk.call( LuaValue.valueOf(script) ).tojstring());

i used this my lua file is in assets i just put print("hello") in my lua file so i should get hello as result in my text view but i always get "nil" in my textview is there any solutions?

1

There are 1 answers

1
Joseph Sible-Reinstate Monica On BEST ANSWER

print("hello") prints "hello" and then returns nil. The value you get from chunk.call is what your Lua code returned, not what it printed.