Changing a Timer

Stupidbro

Veteran
Veteran
Joined
Jul 8, 2019
Messages
87
Reaction score
8
First Language
English
Primarily Uses
RMVXA
So, I recently purchased RPG Maker VX Ace :) and I'm pretty content with it, but I've run into a problem. For my game, I have a spot where a certain portion of the game has to be completed within a certain time frame, otherwise bad things happen (I think I'll make it an automatic game over, but I'm not sure yet). However, my game also includes an inn, but I can't find a way to make it so if the player decides to stay at the inn, it will shorten the amount of time the player has left. Optimally, I would just create two variables, one to store the amount of minutes remaining and one to store the amount of seconds remaining, store the values set by the timer, stop the timer, change the values, then set the timer to the new values, but I can't set the timer's time to a variable.

Does anyone know of an effective work around?
 

standardplayer

Keeper of Kitties
Veteran
Joined
Apr 6, 2016
Messages
698
Reaction score
3,451
First Language
English
Primarily Uses
N/A
You can with script calls. The following will start the timer, and set how many seconds it should be running. You must use seconds as the value, you can't pass it minutes or hours or anything like that.

$game_timer.start(sec * Graphics.frame_rate)
You'll want to replace seconds with a call to the variable holding the value you want to use. If it was variable 20, the call would look like this:

$game_timer.start($game_variables[20] * Graphics.frame_rate)

You would use the above with the Event Command script (last option on the last page of event commands)
$game_timer.stop will obviously stop the timer.


Now, I'm not really very experienced with ruby, so there's probably a better way to do the following, but when you want to capture the total amount of time remaining on the timer itself, in seconds, you can do it like this:

$gameVariable[20] = $game_timer.instance_variable_get:)@count) / 60.

That will return the total amount of seconds left on the timer, and store it in variable 20
 
Last edited:

Stupidbro

Veteran
Veteran
Joined
Jul 8, 2019
Messages
87
Reaction score
8
First Language
English
Primarily Uses
RMVXA
Thank you! It looks like it works, but I'll definitely let you know if I run into any more problems!

I stand corrected. It works up until I actually call for it in the program. I get this:

Script 'Game_Interpreter' line 1411: SyntaxError occurred.

unexpected ')', expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
$gameVariable[17] = $game_timer.instance_variable_get:)@count) / 60.
 
Last edited by a moderator:

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,492
Reaction score
408
First Language
German
Primarily Uses
RMMV
You could use a Script call to advance the functionality of the Eventcommand Timer.
Instead of a fixed value you could use Variable 1 that holds the total seconds which get displayed as minutes and seconds.
On the 3rd Page of Eventcommands you find Eventcommand Script, insert the following there and Game Variable1 will determine the Timer.
Code:
$game_timer.start($game_variables[1] * Graphics.frame_rate)
Now after sleeping at the inn, you can set variable 1 to actual game timer value, thats possible with standard eventcommands.
than you substract the amount of seconds you sleeped.
Than you use the above code to initialise the timer with the new Numbers again.

Here is the Script Call collection:
https://forums.rpgmakerweb.com/index.php?threads/script-call-collection-for-vxace.25759/

Edit: Iam sorry what i wrote was allready written, i should pay more attention to the rules and read first =).
Edit2: But if he enters 120 seconds, the timer will be displayed as 2 minutes and 0 seconds. he doesnt need to go deeper or do i missunderstand the problem?
Edit3: To capture time left on timer, just use Eventcommand Control Variables choose "other" and than "Timer".
 
Last edited:

hiddenone

Lurker Extraordinaire
Global Mod
Joined
Feb 19, 2014
Messages
2,496
Reaction score
5,332
First Language
english
Primarily Uses
RMMZ

@Stupidbro , please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.


You can just edit your previous post to add in something if no one else has posted since your last post. I'll merge them for you this time, but please try to be more careful.
 

Stupidbro

Veteran
Veteran
Joined
Jul 8, 2019
Messages
87
Reaction score
8
First Language
English
Primarily Uses
RMVXA
Is there any way I could have merged them myself?
 

hiddenone

Lurker Extraordinaire
Global Mod
Joined
Feb 19, 2014
Messages
2,496
Reaction score
5,332
First Language
english
Primarily Uses
RMMZ
Nope, only moderators can merge posts. Which is why we ask that people try to be careful to not double-post (though if you do it by accident and realize it, you can just report it and we'll take care of it for you :) ).
 

Stupidbro

Veteran
Veteran
Joined
Jul 8, 2019
Messages
87
Reaction score
8
First Language
English
Primarily Uses
RMVXA
Acknowledged.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,038
Messages
1,018,466
Members
137,821
Latest member
Capterson
Top