I really dont know why its not working bool = false u = false function change() u = true end timer.performWithDelay( 2000, change ,1 ) repeat print( 1 ) if (u == true) then print( "Yea!" ) bool = true break end until bool ~= false
My guess would be that the repeat loop is preventing the change function from being called, because the lua code is never able to escape from it and start the change function (even though you had already called it using a timer).
Using an enterFrame listener is one way around it:
local bool = false local u = false function change() print("change") u = true end timer.performWithDelay( 2000, change ,1 ) local function updateLoop() print( 1 ) if (u == true) then print( "Yea!" ) bool = true Runtime:removeEventListener( "enterFrame", updateLoop ) end end Runtime:addEventListener( "enterFrame", updateLoop )
Thank you bro! :lol:
My guess would be that the repeat loop is preventing the change function from being called, because the lua code is never able to escape from it and start the change function (even though you had already called it using a timer).
Using an enterFrame listener is one way around it:
local bool = false local u = false function change() print("change") u = true end timer.performWithDelay( 2000, change ,1 ) local function updateLoop() print( 1 ) if (u == true) then print( "Yea!" ) bool = true Runtime:removeEventListener( "enterFrame", updateLoop ) end end Runtime:addEventListener( "enterFrame", updateLoop )
Thank you bro! :lol: