The joy of trouble shooting.....

I know the answer to this, but its a bug that bit me and I wanted to share.

Runtime error assertion failed! stack traceback: [C]: ? [C]: in function 'assert' ?: in function 'getOrCreateTable' ?: in function 'addEventListener' ?: in function 'addEventListener' ...cle/Lua/My Game/y Game/level1.lua:195: in function <...cle game><br> ?: in function <?:215><br>

In my program I change my eventListener for enterFrame from moving the camera (think Mario Bros where you can move back and forth until you get to the end and you have to fight the level boss.

All was working well until changed some logic to determine if I was in the end level mode or not:

<br>local attackMode = false<br><br>...<br><br>if onEndScreen then <br> attackMode = true<br>end<br>...<br><br>local function attackMode()<br>... do stuff<br>end<br><br>...<br>...<br>attackMode = true<br><br>Runtime:addEventListener("enterFrame", attackMode)<br>

The moral of the story is you CANNOT use a variable name as a variable AND a function.

Once I added in the flag variable “attackMode” it overwrote my function “attackMode” that did the work.

[import]uid: 19626 topic_id: 18993 reply_id: 318993[/import] </…cle>

Gotta hate it when that happens! LOL :slight_smile:
Walk away moment… [import]uid: 21331 topic_id: 18993 reply_id: 73232[/import]

Good to know. Someone else posted for help in the forums and although I told them to change the variable and function names so they don’t match but I wasn’t totally sure. Now I am. Thanks. [import]uid: 31262 topic_id: 18993 reply_id: 73237[/import]

Hard to find programming bugs when the printed error messages spit out useless information sometimes :expressionless:

I sometimes look for answers on the forums and this will probably be helpful to others. Thank you for sharing.

[import]uid: 38820 topic_id: 18993 reply_id: 73241[/import]

Yea, there are errors like that which will push even the most seasoned programmer to the brink… I definitely had one of (well several) those WTF? moments trying to figure that one out.

[import]uid: 19626 topic_id: 18993 reply_id: 73244[/import]