Cross-platform SDK and HTML5 tools for mobile app development
X
 

MobileLua update

1 post / 0 new
Last post
Mikael Kindborg
miki's picture
Offline
Mobile Sorcerer
Joined: 29 Jun 2010
Posts:
MobileLua update

MobileLua is now updated to work well with MoSync 3.0 and on Windows Phone. There are also new examples that demonstrate how to use NativeUI in Lua. The MobileLua project is found on GitHub: https://github.com/divineprog/mobilelua

New is that all MoSync-related functions and objects are in a global table named "mosync", which puts them in their own namespac.

When you previously wrote "maVibrate(500)", you now write "mosync.maVibrate(500)". If you think "mosync" is too long, you can invent your own prefix, like this:

{syntaxhighlighter brush: cpp;fontsize: 100; first-line: 1; }mo = mosync

mo.maVibrate(500)
{/syntaxhighlighter}

If you don't want to use any prefix at all, you need to assign names to the functions you want to use one-by-one, like this:

{syntaxhighlighter brush: cpp;fontsize: 100; first-line: 1; }maVibrate = mosync.maVibrate

maVibrate(500){/syntaxhighlighter}

Combining JavaScript and Lua is a very powerful option, you can then do the user interface in HTML/CSS, write code in JavaScript, and directly evaluate Lua code from JavaScript. There is a blogpost/video about this: http://www.mosync.com/content/mixing-javascript-and-lua-dynamic-language-interplay

Here is an example program that uses this technique: https://github.com/divineprog/mobilelua/blob/master/projects/LuaLive/Editor/examples/LuaWebView.lua

Best regards, Mikael