MZ More than one timer

Hi,
Is there any existing plugin for rpg maker mz that allows to have more than one timer working at a time and after it ends for example a switch could be turned off?
Basically something like Shaz has done for MV --> link, but for MZ.

It's not something essential, but it would be nice if those timers could be shown somehow as well.
I don't know if there are any or not, but I went ahead and made a little compatibility patch that will let you use Shaz's plugin in MZ. Calling it a "patch" might not even be accurate, since her code was actually still all valid in MZ and I didn't actually need to patch any of it--the only issue is that you need a way to input the plugin commands, so this will give you a script call with which to input one. So I guess that "addon" might be a better word than "patch"?

Anyway, make sure that you have both this plugin, and Shaz's plugin active in your plugin manager, and then you can use this script call to input her plugin commands:

JavaScript:
timerCommand.call(this, "Shaz plugin command");
Just replace Shaz plugin command with one of the plugin commands that she mentioned in her helpfile. So for example, if the plugin command would look like timeLeft MyTimer 12 in MV, then this would be your script call:
JavaScript:
timerCommand.call(this, "timeLeft MyTimer 12");

It's basically that simple, but there are two important caveats to be aware of:

The first is that some of her plugin commands make use of backslashes (this character: \ ), and those behave differently in a script call than they do in a plugin command. So any time you need to use a backslash, you've gotta use two of them. For example instead of \setSS, you would type \\setSS.

The second is is that some of her plugin command use quotation marks, and the script call will also be surrounding the command with quotation marks, so you need to input them a certain way. For example, if the plugin command itself is using single quotes (i.e. 'A'), then you need to make sure that when you stick that plugin command inside the script call, that you do *not* use single quotes to surround the entire plugin command. Use double quotes instead (i.e. "Plugin command"). I don't know if that makes sense, but here is an example of what I mean.

Here is what the plugin command would look like in MV:
Code:
AddTimer MyTimer 60 \setSS([<thismap>, <thisevent>, 'A'], false)

Here is what your script call would look like:
JavaScript:
timerCommand.call(this, "AddTimer MyTimer 60 \\setSS([<thismap>, <thisevent>, 'A'], false)");

Hopefully that all makes sense. Let me know if it doesn't.
I don't know if there are any or not, but I went ahead and made a little compatibility patch that will let you use Shaz's plugin in MZ. Calling it a "patch" might not even be accurate, since her code was actually still all valid in MZ and I didn't actually need to patch any of it--the only issue is that you need a way to input the plugin commands, so this will give you a script call with which to input one. So I guess that "addon" might be a better word than "patch"?

Anyway, make sure that you have both this plugin, and Shaz's plugin active in your plugin manager, and then you can use this script call to input her plugin commands:

JavaScript:
timerCommand.call(this, "Shaz plugin command");
Just replace Shaz plugin command with one of the plugin commands that she mentioned in her helpfile. So for example, if the plugin command would look like timeLeft MyTimer 12 in MV, then this would be your script call:
JavaScript:
timerCommand.call(this, "timeLeft MyTimer 12");

It's basically that simple, but there are two important caveats to be aware of:

The first is that some of her plugin commands make use of backslashes (this character: \ ), and those behave differently in a script call than they do in a plugin command. So any time you need to use a backslash, you've gotta use two of them. For example instead of \setSS, you would type \\setSS.

The second is is that some of her plugin command use quotation marks, and the script call will also be surrounding the command with quotation marks, so you need to input them a certain way. For example, if the plugin command itself is using single quotes (i.e. 'A'), then you need to make sure that when you stick that plugin command inside the script call, that you do *not* use single quotes to surround the entire plugin command. Use double quotes instead (i.e. "Plugin command"). I don't know if that makes sense, but here is an example of what I mean.

Here is what the plugin command would look like in MV:
Code:
AddTimer MyTimer 60 \setSS([<thismap>, <thisevent>, 'A'], false)

Here is what your script call would look like:
JavaScript:
timerCommand.call(this, "AddTimer MyTimer 60 \\setSS([<thismap>, <thisevent>, 'A'], false)");

Hopefully that all makes sense. Let me know if it doesn't.
I've just tested it and it works flawlessly. In case anything seems broken later I might come back here, but it doesn't seem so.
Thank you for your help and explanation. I really appreciate that 🙏
Hello!
I don't know if there are any or not, but I went ahead and made a little compatibility patch that will let you use Shaz's plugin in MZ. Calling it a "patch" might not even be accurate, since her code was actually still all valid in MZ and I didn't actually need to patch any of it--the only issue is that you need a way to input the plugin commands, so this will give you a script call with which to input one. So I guess that "addon" might be a better word than "patch"?

Anyway, make sure that you have both this plugin, and Shaz's plugin active in your plugin manager, and then you can use this script call to input her plugin commands:

JavaScript:
timerCommand.call(this, "Shaz plugin command");
Just replace Shaz plugin command with one of the plugin commands that she mentioned in her helpfile. So for example, if the plugin command would look like timeLeft MyTimer 12 in MV, then this would be your script call:
JavaScript:
timerCommand.call(this, "timeLeft MyTimer 12");

It's basically that simple, but there are two important caveats to be aware of:

The first is that some of her plugin commands make use of backslashes (this character: \ ), and those behave differently in a script call than they do in a plugin command. So any time you need to use a backslash, you've gotta use two of them. For example instead of \setSS, you would type \\setSS.

The second is is that some of her plugin command use quotation marks, and the script call will also be surrounding the command with quotation marks, so you need to input them a certain way. For example, if the plugin command itself is using single quotes (i.e. 'A'), then you need to make sure that when you stick that plugin command inside the script call, that you do *not* use single quotes to surround the entire plugin command. Use double quotes instead (i.e. "Plugin command"). I don't know if that makes sense, but here is an example of what I mean.

Here is what the plugin command would look like in MV:
Code:
AddTimer MyTimer 60 \setSS([<thismap>, <thisevent>, 'A'], false)

Here is what your script call would look like:
JavaScript:
timerCommand.call(this, "AddTimer MyTimer 60 \\setSS([<thismap>, <thisevent>, 'A'], false)");

Hopefully that all makes sense. Let me know if it doesn't.
Just came across this! Thank you for your work <3
I wanted to ask (since I'm not too familliar with coding), is there a way to display those multiple timers? As in have them visible on screen for the player to track them all
I wanted to ask (since I'm not too familliar with coding), is there a way to display those multiple timers?
The description of Shaz's plugin that this is talking about explicitly says "not visible"...so, no.

But I Googled "rpg maker mz multiple timer" and this has a visible option:
The description of Shaz's plugin that this is talking about explicitly says "not visible"...so, no.
It might say that but you could probably call the timer data and display it with a HUD
@AquaEcho Well, yes, if the data exists you can do anything you like with it 😀

But as the previous poster doesn't have the JavaScript knowledge to do so, I thought it was easier to recommend a plugin with the feature advertised as opposed to saying "Yes, there is a way. Good luck."
Thank you everyone for replying! It means a lot!
The description of Shaz's plugin that this is talking about explicitly says "not visible"...so, no.

But I Googled "rpg maker mz multiple timer" and this has a visible option:
I tried the plugin, for some reason nothing seems to happen.. I get no error messages, nothing, not a single timer shows up. I'm not sure if it's due to compatibility issues with my other plugins (mostly VisuStella) or to my own stupidity.
It might say that but you could probably call the timer data and display it with a HUD
@AquaEcho Well, yes, if the data exists you can do anything you like with it 😀

But as the previous poster doesn't have the JavaScript knowledge to do so, I thought it was easier to recommend a plugin with the feature advertised as opposed to saying "Yes, there is a way. Good luck."
Now I know what I said, and lemme confirm it real quick yes I'm absolutely deadloss , but at this point any option is welcome, as it's a feature that I reeeeaaaaallllly want to implement in the game and it needs multiple visible timers to be viable. I'll take anything! Any advice, any tips, any guides, anything, please!
Thank you again!
Edit: I could even pay for it
@AquaEcho Well, yes, if the data exists you can do anything you like with it 😀

But as the previous poster doesn't have the JavaScript knowledge to do so, I thought it was easier to recommend a plugin with the feature advertised as opposed to saying "Yes, there is a way. Good luck."
Eh, took a little work but it's doable.
1693347309839.png

JavaScript:
      $gameVariables.setValue(50, Object.keys(this._timers)[0] + " " + Object.values(this._timers)[0]);

So I guess it comes down to what data Ahstval wants out of there and how he/she wants it displayed
Eh, took a little work but it's doable.
View attachment 274949
JavaScript:
      $gameVariables.setValue(50, Object.keys(this._timers)[0] + " " + Object.values(this._timers)[0]);

So I guess it comes down to what data Ahstval wants out of there and how he/she wants it displayed
I have HUD Maker Ultra by srdude, is there a way to connect the two? to make the timers visible using that?
I have HUD Maker Ultra by srdude, is there a way to connect the two? to make the timers visible using that?
Yes, I'm using the MV version of SRD HUDMaker. Put this line in Shaz's plugin to store the first timer's value into control variable 50. Then have SRD HUDMaker display control variable 50. If you want to show more timers then just add more lines and increment the two variables, e.g. $gameVariables.setValue(51, Object.values(this._timers)[1]); and so on.

E: Actually you're going to have to splice the result to cut the data off where you want because it's going to show all the values stored on the timer, i.e. the remaining timer in milliseconds and what command you told it to do by default.

I'll take a look at this later, I don't have a lot of time right now.

Original thread: https://forums.rpgmakerweb.com/threads/more-than-one-timer.149115/