What I’m trying to do seems to be very simple, but something is going wrong.
I’m trying to alert (system alert) a few messages to the user, one after the other, from a list of messages, where clicking on the “ok” button on the alert message window would initiate the next message.
The code is very simple, but for some reason it does not work past the second message:
local messages\_table = {}; table.insert(messages\_table,{"A","AAA",{"OK"}}); table.insert(messages\_table,{"B","BBB",{"OK"}}); table.insert(messages\_table,{"C","CCC",{"OK"}}); table.insert(messages\_table,{"D","DDD",{"OK"}}); local function trace(title,info,buttons) alert = native.showAlert(title, info, buttons,alert\_listener); end function alert\_listener(event) if event.action == "clicked" then if #messages\_table \> 0 then table.remove(messages\_table,1); trace(messages\_table[1][1], messages\_table[1][2], messages\_table[1][3]); else print("DONE"); end end end trace(messages\_table[1][1], messages\_table[1][2], messages\_table[1][3]);
This code should, by my calculation, alert 4 message, then print “done” when the table of messages is empty.
The first message fires just fine, then the second is fired just fine, and there it stops, no more messages, no “done”, no error message, nothing… almost as if after the second message the listener stops working, or is not taken into account when creating the alert.
Can someone see the problem here and why it does not work??

