"Runtime error: assertion failed!"

I wounder what that error message means, I get it in the context of assigning a touch event to items in a table. Thanks. [import]uid: 109677 topic_id: 24564 reply_id: 324564[/import]

It usually means that a function is not available in the scope of the function call:

local function foo ()  
 print ("FOO")   
 Runtime:addEventListener("enterFrame", bar)  
end  
  
local function bar ()  
 print ("BAR")   
end  
  
foo()  
  
-- output:  
-- FOO  
-- Runtime error  
-- assertion failed!  

you have two options:

  • make the function bar() global by removing the keyword “local”
  • declare the function in the beginning of your code

As you should code everything as “local” as possible (see http://blog.anscamobile.com/2011/07/local-variables-lua/ ), the second option is recommended:

local foo  
local bar  
  
function foo ()  
 print ("FOO")   
 Runtime:addEventListener("enterFrame", bar)  
end  
  
function bar ()  
 print ("BAR")   
end  
  
foo()  

hope that helps :slight_smile:

-finefin

[import]uid: 70635 topic_id: 24564 reply_id: 99460[/import]

yes, thanks, sorry. [import]uid: 109677 topic_id: 24564 reply_id: 99463[/import]

you’re welcome – no need to say sorry :slight_smile:

-finefin [import]uid: 70635 topic_id: 24564 reply_id: 99467[/import]