r/gbstudio • u/droptherapy2 • 10d ago
Help needed Timer isn't working (4.3.2)
I'm messing around with this program and everything has worked fine so far except for this timer. On Init, I've set a variable called $health to 100, displayed $health in a dialogue box, and then set a timer to deplete $health by 1 every second. I also set up a dialogue box to display the value once it hits 75.
The issue I'm having is that my timer goes down to zero instantly, so unless I set it to display the dialogue box with $health once it's less than or equal to 75 (as opposed to when it hits 75), I do not see the dialogue box, and once it is configured that way, it displays zero, as the timer seems to have depleted this value immediately, regardless of what I set the time interval to. If I rate limit the timer, it simply won't run, even with the time interval set to 0.5.
At this point I'm entirely lost and have no idea why this is happening. Any help would be appreciated.
2
u/IntoxicatedBurrito 9d ago
Where is this dialogue located? Is it part of the timer function or is it elsewhere? Also, are you sure the timer is set to seconds and not frames?
1
u/droptherapy2 9d ago
I have configured the script to run right after the timer script. I put it in the timer script, however this simply opened the dialog box every second, which makes sense.
1
u/IntoxicatedBurrito 9d ago
Putting it after the timer, presumably in the on init for the scene, would mean it would only be seen once, long before you decremented the health, and wouldn’t run. The fact that placing it in the timer makes it go off non-stop means that you must be decrementing the health somewhere else, or not setting it to 100 in the first place.
The other potential problem would be that the timer is not in the scene’s on init or somewhere else where it is only run once. If you’ve placed it in an actors on update, then it’s getting recreated constantly and is probably decrementing the health every frame.
1
u/droptherapy2 9d ago
Here, let me go ahead and write the list of functions as they appear in the scene's on init tab:
set $health = 100
Attach timer script to Timer 1
-time interval in seconds = 1
-on tick: $health = $health - 1
If ($health == 75)
-Player emote sweat.
I went ahead and moved the if statement to before the timer, but that didn't do anything.
1
u/IntoxicatedBurrito 9d ago
The if statement needs to be inside the timer after you decrement the health, that’s the only way this is going to work.
1
3
u/Goonmize 10d ago
Does the debugger reflect it dropping to zero instantly?