开发者

Is it possible to use lua scripts in a java android project?

Is it possible to call lua scripts from within java code for the android system? I disc开发者_高级运维overed the Scripting Layer for Android and I have been playing with it on my device, but it would be really useful if I could call lua scripts from within my Eclipse projects. I know that this is possible if I developing on the NDK, but I have no desire to go that way (Java is just too nice). Thanks in advance.


Actually, you can easily port the Lua library to Android using the NDK. Take a look at my attempt - AndroLua that allows you to run scripts, write them using GUI or through the network, and capture output from print function.

It even comes with LuaJava compiled, so you can work with Java objects in Lua, for example, the current running Activity is available in Lua as the global activity, and from that you can call for example activity:setTitle('Modified from Lua').


The Lua interpreter is not shipped with the Android OS. Hence, you either need SL4A or you need to integrate it yourself via the NDK. There is no other possible magic here. Sorry!


I think that you may also use one of Java implementations of Lua.

See here for some links: how can I embed lua in java?


There is SL4A:

http://code.google.com/p/android-scripting/

Also, if you are programming games, you might see the open source Moai project:

http://getmoai.com/


You should take a look at "Kahlua 2" project


Updating this somewhat old question, Corona has been allowing Lua development on Android for some time now. (the subscription fee for publishing Android games is $199/year, but the SDK is a free download for testing purposes)

And the games developed with it will (allegedly) work on the iPhone too (although that'll be another $199/year).

Disclaimer: I'm not affiliated or related with Corona in any way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜