Timer inside another repeating timer doesn't work when the parent timer is repeated

Please add the fix I mentioned here:

Just to be clear, this code has to be added where you handle button clicks.

2 Likes

:face_with_monocle: The inner timer triggers again right after the animation is done.

Cancelling the inner timer when clicking seems to fix the problem:

if action_id == hash("touch") and gui.pick_node(self.button3, action.x, action.y) and action.pressed then
	gui.set_enabled(self.button3, false)
	timer.cancel(self.timer_inner)
	gui.set_enabled(self.text5, true)
end
1 Like

Thanks! I’m using set_visible to work around it. But there’s probably a bug there that needs to be fixed.

Everything works as expected. Here is the sequence:

DEBUG:SCRIPT: 1774939808 outer repeating timer has triggered   <=> start inner timer + enable button
DEBUG:SCRIPT: 1774939809 click and hide                        <=> disable button
DEBUG:SCRIPT: 1774939810 inner timer has triggered             <=> start button animation (animation doesn`t start because button is disabled; animation remains "waiting")
DEBUG:SCRIPT: 1774939812 outer repeating timer has triggered   <=> start inner timer + enable button("waiting" animation can finally start)
DEBUG:SCRIPT: 1774939814 inner animate done                    <=> the "waiting" animation finishes
DEBUG:SCRIPT: 1774939814 inner timer has triggered             <=> start button animation 

As it can be seen, the inner timer doesn’t trigger right after the animation is done but it triggers right after the “waiting” animation is done. This “waiting” animation shouldn’t exist, it should be explicitly canceled when the button is clicked(disabled).

The way to get rid of this “waiting” animation was mentioned here:

In conclusion, there is no bug.

1 Like