Timer Problem

I have a another problem with the timer


I set the control timer on 20 min and


when i play test the game the timer is on 13:40 and next time 10:40 then 7:40


I dont know what the problem is!


Do i need a a Anti-Lag Script or something?
Could you post a screenshot of your event?
Could you post a screenshot of your event?

Ok, Here:


I black out something because you dont want to know the name 😛


one more thing I use a Cool Script for the Timer But that not the problem I Hope


The Script name is "MOG_Active_Timer"


Thanks


TimerThingDontWork.png
Having a link to the script may help as well since what you're using are not normal VX Ace script calls for game timer (which can be found here and are the followings).

Spoiler
# Start Timer
$game_timer.start(sec * Graphics.frame_rate)

# Stop Timer
$game_timer.stop



Now, just because I don't know what your script does I would do something like this:


1: script call to setup timer

Spoiler
$game_timer.start(sec * frames)

#where 20 min = 1200 sec and frames are the number of frames per second of your game (default 60)
#if you didn't change game settings it should be like this

$game_timer.start(1200*60)

2: let your event do what it has to do and when you need to stop the timer just use another script call

Spoiler
@timer = $game_timer.sec
#if you prefer you can change this line to $game_variables[n] = $game_timer.sec
#that if you want to store your time left in a game variable instead of
#using an instance variable...it mostly depend on the use you want to do with
#that variable.

$game_timer.stop

3: when you have to restart your timer just use another script call

Spoiler
$game_timer.start(@timer) #or $game_timer.start($game_variables[n])
#that depends on what variable you used in the previous script call



This should fix your problem. That said (and without reading the script at all)...are you sure that $game_timer.pause should be called BEFORE starting the timer? I have a feeling that it could be the reason you have such a problem.
Having a link to the script may help as well since what you're using are not normal VX Ace script calls for game timer (which can be found here and are the followings).

Spoiler
# Start Timer
$game_timer.start(sec * Graphics.frame_rate)

# Stop Timer
$game_timer.stop



Now, just because I don't know what your script does I would do something like this:


1: script call to setup timer

Spoiler
$game_timer.start(sec * frames)

#where 20 min = 1200 sec and frames are the number of frames per second of your game (default 60)
#if you didn't change game settings it should be like this

$game_timer.start(1200*60)

2: let your event do what it has to do and when you need to stop the timer just use another script call

Spoiler
@timer = $game_timer.sec
#if you prefer you can change this line to $game_variables[n] = $game_timer.sec
#that if you want to store your time left in a game variable instead of
#using an instance variable...it mostly depend on the use you want to do with
#that variable.

$game_timer.stop

3: when you have to restart your timer just use another script call

Spoiler
$game_timer.start(@timer) #or $game_timer.start($game_variables[n])
#that depends on what variable you used in the previous script call



This should fix your problem. That said (and without reading the script at all)...are you sure that $game_timer.pause should be called BEFORE starting the timer? I have a feeling that it could be the reason you have such a problem.

It work fine but there is a graphics Bug when i use the Script Call thing anyway


Here is the Script Code thing
Ehm, which one works fine? The part with normal VX Ace script calls or the part without the $game_timer.pause at the beginning of the event?


Oh, and knowing which graphic bug you're having would also be useful
Ehm, which one works fine? The part with normal VX Ace script calls or the part without the $game_timer.pause at the beginning of the event?


Oh, and knowing which graphic bug you're having would also be useful

When I use the normal control timer it dont work


but when i use the script call it work Awesome But the problem is:


I dont know how i can show you but i found This website and upload the video I hope it work!
Don't worry, I found it myself looking into the script code you provided. The previous question was a dumb question and you answered right before I could edit the post.


The problem is that the script you are using overwrites command_124 in Game_Interpreter.


To cut it short: it changes the way your "Control Timer" option on the event works but it also changes the way you have to call it using a script call.


It adds more lines to that one so, if you want to activate your timer correctly you have to add these line in your script call as well. Without going in depth with that you have to add these lines every time you have a script call to start your timer.


#here is your script call to start your timer
$game_system.timer_prev = $game_timer.count - 60
$game_system.timer_prev = 1 if $game_timer.count <= 0


In the end it should look like this:


$game_timer.start(your_value)
$game_system.timer_prev = $game_timer.count - 60
$game_system.timer_prev = 1 if $game_timer.count <= 0




This works but when you stop your timer and restart it your flowing bar will reset and it will start with the correct time but the wrong bar completion. That only means your bar will move faster, the timer will still work right, but you WILL have this problem.


EDIT:


@iTzTerra: there is actually a way to fix that and let the timer appear half-depleted after you start your timer again. You can update it manually with a script call like this:

Spoiler
Code:
#this is the 1st script call, I am starting my timer for the 1st time
@my_time = (20 * 60) #I am using 20 sec so this will be easier to see
$game_timer.start(@my_time)
$game_system.timer_prev = $game_timer.count - 60
$game_system.timer_prev = 1 if $game_timer.count <= 0
#end of the 1st script call


#this is the 2nd script call, the one I use to pause the timer
@var = 60*$game_timer.sec #That 60* only means I don't have to use it later
$game_timer.stop
#end of the 2nd script call


#this is the 3rd script call, the one I use to resume the timer
$game_timer.start(@my_time) #<-I am using the same as before, not @var
$game_system.timer_prev = $game_timer.count - 60
$game_system.timer_prev = 1 if $game_timer.count <= 0
#Here we update our timer manually
for i in 0..(@my_time - @var)
	$game_timer.update
end
#@my_time - @var gives you the time passed before pausing the timer



That said, I still think that in your case you could just start your timer at the end of the event. Since the player cannot really do anything while the event runs it's pointless to start it, then stop it, then start it again.
Don't worry, I found it myself looking into the script code you provided. The previous question was a dumb question and you answered right before I could edit the post.


The problem is that the script you are using overwrites command_124 in Game_Interpreter.


To cut it short: it changes the way your "Control Timer" option on the event works but it also changes the way you have to call it using a script call.


It adds more lines to that one so, if you want to activate your timer correctly you have to add these line in your script call as well. Without going in depth with that you have to add these lines every time you have a script call to start your timer.



#here is your script call to start your timer
$game_system.timer_prev = $game_timer.count - 60
$game_system.timer_prev = 1 if $game_timer.count <= 0


In the end it should look like this:



$game_timer.start(your_value)
$game_system.timer_prev = $game_timer.count - 60
$game_system.timer_prev = 1 if $game_timer.count <= 0




This works but when you stop your timer and restart it your flowing bar will reset and it will start with the correct time but the wrong bar completion. That only means your bar will move faster, the timer will still work right, but you WILL have this problem.


EDIT:


@iTzTerra: there is actually a way to fix that and let the timer appear half-depleted after you start your timer again. You can update it manually with a script call like this:

Spoiler
#this is the 1st script call, I am starting my timer for the 1st time
@my_time = (20 * 60) #I am using 20 sec so this will be easier to see
$game_timer.start(@my_time)
$game_system.timer_prev = $game_timer.count - 60
$game_system.timer_prev = 1 if $game_timer.count <= 0
#end of the 1st script call


#this is the 2nd script call, the one I use to pause the timer
@var = 60*$game_timer.sec #That 60* only means I don't have to use it later
$game_timer.stop
#end of the 2nd script call


#this is the 3rd script call, the one I use to resume the timer
$game_timer.start(@my_time) #<-I am using the same as before, not @var
$game_system.timer_prev = $game_timer.count - 60
$game_system.timer_prev = 1 if $game_timer.count <= 0
#Here we update our timer manually
for i in 0..(@my_time - @var)
$game_timer.update
end
#@my_time - @var gives you the time passed before pausing the timer



That said, I still think that in your case you could just start your timer at the end of the event. Since the player cannot really do anything while the event runs it's pointless to start it, then stop it, then start it again.

Thanks for the help you saved the map i work on if it didn't I would almost delete the map or something Anyways Thanks


TimerMaybeWorkingThanks.png
You're welcome, I am glad it helped you. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/timer-problem.70000/