LBGames

Regular
Regular
Joined
Mar 9, 2020
Messages
62
Reaction score
19
First Language
English
Primarily Uses
RMMV
Awesome! In the next version, I will add an option to reset the timer, so you will just be able to do it as you originally did, with 'reset', and it will add 1 to the variable every second (or whatever your delay is).

That would be good. What would be really cool would be a way to speed up or slow down a timer. I was thinking of doing a "rest for x hours" event, but that seems like a headache, so I'll just do rest until night or morning.
 

MichaelRIR

Niakat on Discord
Regular
Joined
Oct 29, 2020
Messages
48
Reaction score
25
First Language
English
Primarily Uses
RMMZ
Hey Shaz! Any chance this could be ported to MZ? Would be a huge help for me to use in conjunction with the Encounter Effects plugin. All my enemies are on the map and I've love to have them respawn after a given time.
 

Shaz

Keeper of the Nuts
Global Mod
Joined
Mar 2, 2012
Messages
46,153
Reaction score
16,960
First Language
English
Primarily Uses
RMMV
I thought someone had already done a multi timer plugin for MZ?
 

stramin

Regular
Regular
Joined
Nov 4, 2012
Messages
395
Reaction score
192
First Language
spanish
Primarily Uses
N/A
Do the timers persist after loading a game?

for example, I have 4 crops (4 timers) and they need 2 hours to grow up, and I save the game when there were 30 minutes remaining, if I quit the game and load the game later, Will the 4 timers continue at 30 minutes remaining?
 

mfexplorer

Regular
Regular
Joined
Aug 9, 2022
Messages
89
Reaction score
19
First Language
English
Primarily Uses
RMMZ
Hey Shaz! Any chance this could be ported to MZ? Would be a huge help for me to use in conjunction with the Encounter Effects plugin. All my enemies are on the map and I've love to have them respawn after a given time.
Hi, is this plugin available for MZ or something equivalent. It would be extremely useful to me also.
 

Katevolution

Villager
Member
Joined
Aug 24, 2021
Messages
29
Reaction score
7
First Language
English
Primarily Uses
RMMV
Is there a way to set the time remaining/passed into a Variable? So like if I set a timer for 100 seconds and 20 passed, I can set V1 to 20 or 80.
 

Arthran

Regular
Regular
Joined
Jun 25, 2021
Messages
1,092
Reaction score
1,573
First Language
English
Primarily Uses
RMMZ
Hi, is this plugin available for MZ or something equivalent. It would be extremely useful to me also.
Dunno if you're still looking or not, but this might help.

Is there a way to set the time remaining/passed into a Variable? So like if I set a timer for 100 seconds and 20 passed, I can set V1 to 20 or 80.
Unless I'm misunderstanding your question, I'm pretty sure that's what this plugin command does:
Code:
TimeLeft key variableId
 
Last edited:

Katevolution

Villager
Member
Joined
Aug 24, 2021
Messages
29
Reaction score
7
First Language
English
Primarily Uses
RMMV
Unless I'm misunderstanding your question, I'm pretty sure that's what this plugin command does:
Code:
TimeLeft key variableId

Well I'll be, that is exactly what I was asking. Thanks! :LZSjoy:

Edit: So it is, but it isn't. I'm trying to set a Self Variable ( http://www.yanfly.moe/wiki/Self_Switches_&_Variables_(YEP) ) to the remaining time. I thought I saw it on the list but doesn't seem so. Unless I'm missing it again. Any idea on how to do that?
 
Last edited:

Arthran

Regular
Regular
Joined
Jun 25, 2021
Messages
1,092
Reaction score
1,573
First Language
English
Primarily Uses
RMMZ
Well I'll be, that is exactly what I was asking. Thanks! :LZSjoy:

Edit: So it is, but it isn't. I'm trying to set a Self Variable ( http://www.yanfly.moe/wiki/Self_Switches_&_Variables_(YEP) ) to the remaining time. I thought I saw it on the list but doesn't seem so. Unless I'm missing it again. Any idea on how to do that?

Ah, yeah, a self variable would be a bit different. I didn't have time to test it, since I'm on my way to bed, but give this a try. Save this into a new .js file and add it to your project through the plugin manager:
JavaScript:
/*:
 * @plugindesc Shaz Multi_Timers + YEP_SelfSwVar compatibility patch
 * @author Arthran
 *
 * @help
 * Allows you to save the time left in a timer into a self variable,
 * using this plugin command:
 *   TimeLeftSV key variableId
 *
 * Free for use in any kind of project. No credit necessary
 */

(() => {
    const _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        if (command.toUpperCase() == 'TIMELEFTSV') {
            args = this.subst(args);
            let key = args.shift();
            let varId = parseInt(args.shift());
            let timeLeft = $gameTimer.hasTimer(key);
            $gameTemp.setSelfSwVarEvent(this._mapId, this._eventId);
            $gameVariables.setValue(varId, timeLeft ? timeLeft : 0);
            $gameTemp.clearSelfSwVarEvent();
        } else {
            _Game_Interpreter_pluginCommand.call(this, command, args);
        }
    };
})();

And try this plugin command:
Code:
TimeLeftSV key variableId
 

Katevolution

Villager
Member
Joined
Aug 24, 2021
Messages
29
Reaction score
7
First Language
English
Primarily Uses
RMMV
Ah, yeah, a self variable would be a bit different. I didn't have time to test it, since I'm on my way to bed, but give this a try. Save this into a new .js file and add it to your project through the plugin manager:
JavaScript:
/*:
 * @plugindesc Shaz Multi_Timers + YEP_SelfSwVar compatibility patch
 * @author Arthran
 *
 * @help
 * Allows you to save the time left in a timer into a self variable,
 * using this plugin command:
 *   TimeLeftSV key variableId
 *
 * Free for use in any kind of project. No credit necessary
 */

(() => {
    const _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        if (command.toUpperCase() == 'TIMELEFTSV') {
            args = this.subst(args);
            let key = args.shift();
            let varId = parseInt(args.shift());
            let timeLeft = $gameTimer.hasTimer(key);
            $gameTemp.setSelfSwVarEvent(this._mapId, this._eventId);
            $gameVariables.setValue(varId, timeLeft ? timeLeft : 0);
            $gameTemp.clearSelfSwVarEvent();
        } else {
            _Game_Interpreter_pluginCommand.call(this, command, args);
        }
    };
})();

And try this plugin command:
Code:
TimeLeftSV key variableId

Thanks! I tested and it appears to be working :). Even did it on multiple Events and they each showed their own number.
 

mfexplorer

Regular
Regular
Joined
Aug 9, 2022
Messages
89
Reaction score
19
First Language
English
Primarily Uses
RMMZ
This is a very cool plugin. The only thing that seems to be missing is that you cannot use a variable to define the number of seconds the timer will run for.

e.g.
addTimer randomMonster \v[170] \sets(110, true) instead of

addTimer randomMonster 60 \sets(110, true)

Would it be hard to add this or is it already there and I'm doing it wrong.
 

Katevolution

Villager
Member
Joined
Aug 24, 2021
Messages
29
Reaction score
7
First Language
English
Primarily Uses
RMMV
This is a very cool plugin. The only thing that seems to be missing is that you cannot use a variable to define the number of seconds the timer will run for.

e.g.
addTimer randomMonster \v[170] \sets(110, true) instead of

addTimer randomMonster 60 \sets(110, true)

Would it be hard to add this or is it already there and I'm doing it wrong.
If you have the Yanfly Plugins, "Plugin Commands - Switches & Variables Access (YEP)" will do exactly that.
 

raffle

Regular
Regular
Joined
Oct 25, 2020
Messages
123
Reaction score
57
First Language
English
Primarily Uses
RMMV
I have been using this plugin for a while and its a lifesaver :3

Was just wondering if there's a way to individually pause timers?
For example when there's dialogue going on, I wanted to pause certain things, and then resume after the dialogue is over.

I have tried using $gameTimer.pause(); and $gameTimer.resume(); and they work fine but those affect ALL timers in the game. :kaocry:
 

FriendSized

Just the right size!
Regular
Joined
Dec 22, 2022
Messages
94
Reaction score
95
First Language
English
Primarily Uses
RMMV
I'm trying to delete all timers running on a map before I leave a map.

I set up a quick event that just runs this Plugin Command:

Code:
deleteTimer <thismap>

But I don't think I'm using this command correctly because it's not deleting the timer. Can someone show me what I'm doing wrong?
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,071
Reaction score
8,994
First Language
English
Primarily Uses
RMMV
I'm trying to delete all timers running on a map before I leave a map.

I set up a quick event that just runs this Plugin Command:

Code:
deleteTimer <thismap>

But I don't think I'm using this command correctly because it's not deleting the timer.

Yeah, that doesn't look right. From the documentation:
DeleteTimer key
...
key is any text/number string without spaces, that uniquely identifies the timer
bolded emphasis mine.

So those commands can never support you deleting multiple timers at once, because each key had to be unique. What you typed would delete a timer you created with AddTimer <thismap> but no others.

Shaz would certainly know better, but with a quick poke at the code it doesn't look the timers have any reference to being "owned" by or "contained" in a map - you can just use the map's ID as a part of your unique key.

So there would be no built-in way to just iterate through all of the timers contained by a map, you have to just delete them individually.

My two cents.
 

Katevolution

Villager
Member
Joined
Aug 24, 2021
Messages
29
Reaction score
7
First Language
English
Primarily Uses
RMMV
So there would be no built-in way to just iterate through all of the timers contained by a map, you have to just delete them individually
Would it be possible to add another line at their creation to add the key to an array and then at transfer do "For Each in [Array] do DeleteTimer [key]" and then clear it? I'm sure that's not the correct command but hopefully you know what I'm getting at :)
 

FriendSized

Just the right size!
Regular
Joined
Dec 22, 2022
Messages
94
Reaction score
95
First Language
English
Primarily Uses
RMMV
Yeah, that doesn't look right. From the documentation:

bolded emphasis mine.

So those commands can never support you deleting multiple timers at once, because each key had to be unique. What you typed would delete a timer you created with AddTimer <thismap> but no others.

Shaz would certainly know better, but with a quick poke at the code it doesn't look the timers have any reference to being "owned" by or "contained" in a map - you can just use the map's ID as a part of your unique key.

So there would be no built-in way to just iterate through all of the timers contained by a map, you have to just delete them individually.

My two cents.
That makes sense, especially since I am using the plugin command:

Code:
AddTimer <thismap>.<thisevent> 20 \setSS([<thismap>,<thisevent>,'B'],true)

I did try:

Code:
deleteTimer <thismap>.<thisevent>

just to see what would happen, but nothing did - which was expected.

The contributing factor I'm probably also running up against is that I'm using the timer in conjunction with Galv's Event Spawner to create random nodes on the map that gives the player an item when clicked, but disappears when the timer runs out.

And it does work perfectly - I can spawn and despawn as many events as I want all on different timers. And I can also despawn all the events on the map when I leave the map with Galv's plugin, but I just can't get the timers to go away. So even though the event technically despawned, the timer is still there running in the background and then when the timer runs out (in my case after 20) it runs the event on self switch 'B' anyway (which is a quick animation and a variable reset.

And since I'm duplicating the same event multiple times (right now I have about 15 per map) I haven't been able to figure out how to give each event a unique timer key that I can directly call and turn off since they're all technically the same event.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,071
Reaction score
8,994
First Language
English
Primarily Uses
RMMV
Would it be possible to add another line at their creation to add the key to an array and then at transfer do "For Each in [Array] do DeleteTimer [key]" and then clear it?
Yes, but that would be a request to Shaz to edit the plugin for that functionality.

One could do it manually, but then you'd be doing the whole thing through JavaScript and bypassing the functionality of the keywords provided by the plugin commands.
 

Arthran

Regular
Regular
Joined
Jun 25, 2021
Messages
1,092
Reaction score
1,573
First Language
English
Primarily Uses
RMMZ
That makes sense, especially since I am using the plugin command:

Code:
AddTimer <thismap>.<thisevent> 20 \setSS([<thismap>,<thisevent>,'B'],true)

I did try:

Code:
deleteTimer <thismap>.<thisevent>

just to see what would happen, but nothing did - which was expected.

The contributing factor I'm probably also running up against is that I'm using the timer in conjunction with Galv's Event Spawner to create random nodes on the map that gives the player an item when clicked, but disappears when the timer runs out.

And it does work perfectly - I can spawn and despawn as many events as I want all on different timers. And I can also despawn all the events on the map when I leave the map with Galv's plugin, but I just can't get the timers to go away. So even though the event technically despawned, the timer is still there running in the background and then when the timer runs out (in my case after 20) it runs the event on self switch 'B' anyway (which is a quick animation and a variable reset.

And since I'm duplicating the same event multiple times (right now I have about 15 per map) I haven't been able to figure out how to give each event a unique timer key that I can directly call and turn off since they're all technically the same event.
Provided that you are adding all of your timers with your key in that exact format, you can delete all timers from a the current map using this script call:

JavaScript:
const mapId = this._mapId;
const regex = new RegExp(`${mapId}\\.\\d+`);
Object.keys($gameTimer._timers).forEach(key => {
    if (regex.test(key)) {
        $gameTimer.deleteTimer(key);
    }
});

That is assuming that you are running the script call from the same map that is in question.
 

Latest Threads

Latest Posts

Latest Profile Posts



Very well, ladies and gentlemen, here I leave you fresh from the oven, the Plugin you have been waiting for: Dynamic Switches! (For rpg maker MZ) I hope you like it!

As always, you can try it for FREE on my Itchio page, and expand its capabilities with the FULL version.
Type A demo coming up this week! Here's what to expect (this is a trailer of sorts)
I was messing around with timings and kinda created the green shell minigame from Mario and Luigi: BIS.
It was too goofy not to share XD
Was real busy today but I found a few minutes to start on the named cultists and how to give each of them visually distinctive morphology within the confined of the cult robes. I really dislike straight recolors so I trying real hard with the small details on these.

Forum statistics

Threads
134,835
Messages
1,251,059
Members
177,631
Latest member
hyder
Top