How do I run Lua scripts on Android in a Java application?

后端 未结 4 842
孤街浪徒
孤街浪徒 2021-02-01 09:29

I\'m developing an Android game in Java which uses Lua scripts. To execute these scripts, I\'m using LuaJ with Java\'s ScriptEngine class. For example...

ScriptE         


        
4条回答
  •  遇见更好的自我
    2021-02-01 09:46

    To use Lua on Android, you can use JNLua + Lua 5.2 (implemented in C). The only Android port with JSR 223 (javax.script) support is here: https://github.com/danke-sra/jnlua-android

    Using this port, you can do what you want:

    ScriptEngine scriptEngine = new LuaScriptEngineFactory().getEngine(); scriptEngine.eval("lua statements");

提交回复
热议问题