6

Is it possible to call lua scripts from within java code for the android system? I discovered 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.

Kiril
  • 2,091
  • 7
  • 33
  • 43
  • Checkout http://sourceforge.net/projects/luaj/ you have there example fot android. Use luaj-jse-3.0.jar – Gelldur Mar 04 '15 at 14:08

6 Answers6

19

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').

Michal Kottman
  • 16,375
  • 3
  • 47
  • 62
8

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!

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
2

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?

Community
  • 1
  • 1
Alexander Gladysh
  • 39,865
  • 32
  • 103
  • 160
0

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/

polypus74
  • 429
  • 4
  • 8
0

You should take a look at "Kahlua 2" project

Paco Barter
  • 182
  • 1
  • 3
0

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.

kikito
  • 51,734
  • 32
  • 149
  • 189