In some function I have code:
while eNum \<= 5 do math.randomseed( os.time() ) local i = math.random (1 , 10) local j = math.random (1 , 10) if not enemyTab[i][j].hasSph then enemyTab[i][j].hasSph = 1 local enemySph = display.newImageRect( mainGroup, objectSheet, 9, 50, 50 ) enemySph.x = enemyTab[i][j].x enemySph.y = enemyTab[i][j].y eNum = eNum + 1 wait(3) else eNum = eNum - 1 wait(3) end end
It works fine with wait function which is:
function wait(waitTime) timerOS = os.time() repeat until os.time() \> timerOS + waitTime end
But if I cooment line wait(3) cycle become endless and eNum is negative number (rising all the time).
Can’t understand where my mistake?