after having searched the forums for what seems like an endless time, i decided to ask for help now!
my problem is :
i’m making a game where after x’ amount of time the game goes to shop.lua from there, goes back to game.lua but with increased x amount of time!
so i use a timer to do this obviously, and i use: composer.setVariable (“endRoundTimer”,timer + 5) to increase the time! however, after having played first ‘round’ i get to shop as meant to be. but, when i go from there back to the game i get this error message : lua:368: attempt to index global ‘timer’ (a number value)
now this seems like scoping issues obviously but i dont get it! my timer is this :
[lua]
local countDownTimer = timer.performWithDelay( 1000 , updateEndTimer,-1)
[/lua]
the function it runs is this :
[lua]
local function updateEndTimer() --here it goes to shop after timer
--decrement time
endRoundTimer = endRoundTimer - 1
--remove old text
display.remove(RoundText)
--print it to screen
RoundText = display.newText ( uiGroup, "Time: " … endRoundTimer, 400, 150, native.systemFont, 36 )
if (endRoundTimer == 0) then
endTimer = timer.performWithDelay( endGameDelay, toShop )
end
end
[/lua]
really hope u can shine some light on this issue! looking forward to your responses!