Tutorial :Lua on the iPhone



Question:

I'm trying to load at run-time Lua scripts on the iPhone. Is there a possibility to do that?

How can I getting started with Lua? I can't find something. The only thing I can find is that this should be possible, but I am wondering how.


Solution:1

Check out the Corona SDK.


Solution:2

the Lua docs are very good, also read PIL (Programming in Lua) first edition is available online, the second edition is inexpensive on hard copy.

Lua is specifically designed to be used as an embedded language, simply link to any C (or Obj-C, or C++) project, and use the C API to load scripts and run them.

Note that Apple forbids to create scripting platforms; but AFAICT, that only means that the user shouldn't be able to add Lua scripts to enhance your app. You're free to use embedded Lua to make your App more flexible and easier to write.


Solution:3

See also iPhone Wax: http://github.com/probablycorey/wax


Solution:4

I have compiled Lua into an iPhone app. It is fairly straight forward if you have used Lua in other contexts. The only real gotcha is that the iPhone doesn't expose its file system in a traditional way so I ended up using the resource bundle to store scripts and had to rewrite the lua_dofile function to accept files from the bundle.

I would recommend compiling Lua into a non-iPhone app before attempting to use it on the iPhone. Once you understand the c api shoehorning it into the cocoa mobile framework is not that hard.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »