lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Aug 30, 2012 at 1:04 PM, Michal Kottman <k0mpjut0r@gmail.com> wrote:
> Since I cannot attend in person, I am really looking forward to see
> the video online. I have never thought that my experiment in "can this
> be done?" will become an inspiration for a talk :)

Oh, it is very entertaining to make changes and have a screen
immediately appear. Perhaps I have a kind of attention deficit
disorder, but waiting several seconds for an app to be packaged and
pushed up makes my mind wander! [1]  (Clearly I am unsuitable for C++)

Lua's great flexibility makes the original API much more bearable, and
an interactive prompt is great for experimentation and learning.

Here's the current state of the art for writing an Activity in Lua:

-- simple.lua
simple = require 'android'.new()

function simple.create (me)
    local edit = me:editText 'search...'
    local txt = me:textView ''
    local btn = me:button('OK',function  ()
        me:toast('text '..edit:getText():toString())
    end)
    return me:vbox {
        me:hbox{
            edit,'+',
            btn,
        },
        txt
    }
end

return simple

There are the usual limitations of Lua (mostly threading support) and
also LuaJava limitations, such as being unable to call JVM methods
from within a coroutine.  But that is a fixable issue, and a little
tactical use of Java is no bad thing.

steve d.

[1] Anything below 100ms is considered 'instantaneous' by humans. So
we can think of that as the basic clock cycle. Then the real measure
of waiting is 100ms ticks....