I'm developing a slot machine-style mini-game in App Inventor that includes a cooldown system after a limited number of attempts. I'm using TinyDB to store:
The number of remaining attempts (remainingSlotAttempts)
The cooldown time in seconds (remainingCooldownSeconds)
The Goal
Once the player uses up all 5 attempts, a 300-second (5-minute) cooldown should start. During this time, a countdown is displayed using a Clock component (RelojEspera). After the countdown finishes, the 5 attempts are restored automatically.
The Issue
Even though:
The global Cooldown value is saved and updated correctly,
RelojEspera.TimerEnabled is set to true,
The block when RelojEspera.Timer exists in the project,
β¦ the timer event never fires, and the countdown does not update on screen.
What I've tried so far
Confirmed that RelojEspera is on the current screen.
Made sure its TimerInterval is set to 1000 ms.
Placed alerts inside the Timer event block to confirm if it runs (it doesn't).
Tried re-enabling the timer in multiple ways after setting the cooldown value.
Checked for any other block that could be disabling the timer β found none.
Key Blocks
I've attached screenshots of the relevant blocks in this thread.
What could prevent a timer from firing even if itβs enabled and its interval is set properly? Could this be related to execution order or how App Inventor handles enabling timers?
Yes. I think i have set it. I tested with limited time of 5 in cooldown when the user used up all of his attempts. And as per the code now it triggers . Once the cooldown finish again the game starts, meanwhile if the user reopens the open cooldomw begins from where he left. But remember if the user clears data then everything wil reset.
But this logic says, user either need to wait compulsorily 5 min to play and even if he comeback after few hours. instead you do alter the logic such a way that when the user lost his 5 attempts get current time in milli and add 300000 with it and save it as end time. and find the difference between this saved time with current time. if the difference goes in negative even if he come back after few min or hr, clears the end time with zero. suppose if h come to ap less than 5 min from the last click timer, then the difference will give you in positive value and let the user to wait until the difference goes less than 100
The Clock Timer has been given the responsibilities:
Keeping the displayed cooldown time up to date
watching for a disabled Play Button whose cooldown limit has been reached or passed, and reviving it with a fresh Play count to begin its new play cycle.
Notice that I use NO global variables, working only off TinyDB and the display Labels.
This avoids confusion as to where the one and only truth resides.
The Play button decreases its remaining count each time it is clicked.
When it runs out of remaining Plays, it disables itself.
Notice how the Play Button's dying act after it discovers it has been disabled is to set up the end of cooldown time in TinyDB, to let the Clock Timer revive it at the appointed time.
Some time formatting procedures:
Formatting for output and guarding against overdue cooldown end: