Multi Timers

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,533
Reaction score
12,057
First Language
English
Primarily Uses
RMMV
Multi Timers
2015.11.14
by Shaz

Introduction
This plugin allows you to have multiple timers running at once, with no timer display, to execute any command after counting down

How to use
Add to your plugins folder (name is irrelevant but I use MultiTimers.js). There are no parameters to set.

Plugin commands are:
AddTimer key seconds command
DeleteTimer key
HasTimer key switchId
TimeLeft key variableId

key is any text/number string without spaces, that uniquely identifies the timer, and can be used later to cancel/delete it, see if it is running, and how much time is left. Using the same key in subsequent AddTimer plugin commands replaces the existing timer with the newest one.
seconds is the number of seconds for the timer to count down.
command is the command to run after countdown completes. This can be any command to run, but would normally be turning a switch on or off, setting a self switch, or changing a variable.
switchId is the switch id to be turned on if there is a timer with the specified key.
variableId is the variable id to be set to the number of seconds remaining on the timer. If there is no timer with the specified key, the variable will be set to 0.

Keywords that can be used anywhere in the plugin command are:
<thismap> - current map's id
<thisevent> - current event's id
\setSS - set a self switch - format is \setss([map, event, 'A'], true)
\ss - the value of a self switch - format is \ss([map, event, 'A'])
\setS - set a switch - format is \sets(switchId, true)
\s - the value of a switch - format is \s(switchId)
\setV - set a variable - format is \setv(variableId, value)
\v - the value of a variable - format is \v(variableId)

See plugin documentation for examples


Plugin
Download from pastebin

Credit
- Shaz

Terms
- free for use in commercial games

Notes
- if you need help setting or checking a timer, post below and I'll help you with the plugin command

- let me know if you can think of other keywords that might be useful - I couldn't really come up with much
 
Last edited by a moderator:

djDarkX

Retro & Remastered Music Guru
Veteran
Joined
Jan 17, 2013
Messages
2,699
Reaction score
1,889
First Language
Music
Primarily Uses
RMMV
This has a plethora of uses!  Nice going, Shaz!  Might grab this later for a different project.
 

sertianscompany

Villager
Member
Joined
Nov 26, 2015
Messages
16
Reaction score
5
First Language
ESP EN
Great, but is it possible to show more than one timer on the screen? thanks! ;)
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,533
Reaction score
12,057
First Language
English
Primarily Uses
RMMV
This plugin does not show timers on the screen at all. You will need a different plugin for that.
 

Percival

Villager
Member
Joined
Aug 21, 2014
Messages
14
Reaction score
0
First Language
Italian
Primarily Uses
How can i set a switch to turn off?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,533
Reaction score
12,057
First Language
English
Primarily Uses
RMMV
If your switch is switch 18, and you want it turned off after 3 minutes (180 seconds), the plugin command would be:

Code:
AddTimer Switch18Off 180 \sets(18, false)
The Switch18Off can be any name you want it to be - it just identifies it uniquely so you can check it later if you have a need, but mostly to make sure something else doesn't overwrite it with a different timer.
 

Rafael_Sol_Maker

Almighty God Jabu
Veteran
Joined
May 8, 2012
Messages
122
Reaction score
36
First Language
Portuguese
Primarily Uses
RMMV
Pretty dum useful. Good job, Shaz! These scripts are the best, because it give options and flexibility to games (nothing against fancy Battle Systems, ahem).

I will test the compatibility with my Timer Expansion. If you don't care, maybe I will write an compatibility script for it, so we can have the best of both worlds (timers on and offscreen)

Although I think I will need to write a script for a future project to put multiple timers on screen (not as HUD, but in-game, I should say).
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,533
Reaction score
12,057
First Language
English
Primarily Uses
RMMV
sure - take what you need :)
 

Shake0615

Reanimator
Veteran
Joined
Nov 3, 2012
Messages
118
Reaction score
65
First Language
English
Primarily Uses
RMMV
Every time I use Delete Timer, no matter the circumstance, it crashes and says "Type Error undefined is not a function." I tried it in a blank project and it still had the same error. I basically do it like this:

Code:
Event 1:
addTimer timer1 75 \sets(10, true)
timeLeft timer1 7

Event 2:
deleteTimer timer1

Crashes immediately.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,533
Reaction score
12,057
First Language
English
Primarily Uses
RMMV
Thanks for reporting this.  I've found and fixed the problem.  Please download again from pastebin for the updated version.
 

Veralisa

Villager
Member
Joined
Feb 22, 2016
Messages
16
Reaction score
8
First Language
English
Primarily Uses
Would this work for an open-world harvesting system? Say for example, I have hundreds of carrots spread over my maps that you can pick once every x days. I'd just have to use the 'self-switch off' plugin command to make them harvestable again? If yes, I have a couple of questions!


1. Will having hundreds of respawnable events across the whole game cause lag? It seems like it might be heavy to manage.


2. I was just wondering if the timer keeps counting down when the game isn't running! I was thinking a 24 irl hours respawn, so 86400 seconds? xD Is that 86400s worth of actual playtime, or just real life time? S:


3. Do you have any plans to make the timers compatible with other time systems (e.g. I'm using Orange Time System) to make them work with game time instead?


Thank you so much! I've been banging my head against the wall and wasting mannyyyy hours trying to event a crops-respawn system to no avail.
 

MySwordSmitesAll

Villager
Member
Joined
Jul 19, 2016
Messages
6
Reaction score
0
First Language
English
Primarily Uses
Weird, my Windows Defender is going crazy when I try to download this script. It's never done that for other ones; has the link been compromised? It's detecting "Trojan: Win32/Spursint.A!cl".
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,533
Reaction score
12,057
First Language
English
Primarily Uses
RMMV
@Veralisa I'm so sorry I haven't seen your post until now - I was away from the forums more frequently for a few months starting in February, so it was hard to stay up to date, and you didn't tag me.


1. It might.  It checks on every frame to see if there are any timers that are due to be triggered.  If you have a few hundred of them, that might slow things down a bit.  The only way to tell is to actually give it a go and check.


2. No, the timer works on game seconds, not real time.  So it only counts down while the game is being played.


3. No, I write my scripts and plugins to suit my project, and I share them if I think others will find it useful.  I don't have time to go looking at all other systems to see if I need to change them to be compatible.  You are very welcome to ask for someone else to make a patch or modify the plugin to make them compatible - even if you want to pay someone to do this.  They would need to add a note that they'd done edits though, so it's clear it's not MY timer system as I designed it.  However, doesn't Hudell have some kind of similar timer system that would work with the Orange Time System?


@MySwordSmitesAll You're downloading it wrong.  Javascript is executable code, so anytime you try to download a .js file, this is going to happen.  What you need to do is click the RAW button at that link, then copy the code, paste it into a blank text document (using notepad or something similarly basic - not MS Word), and save it as a javascript file (to ensure the extension stays as .js and doesn't get changed to .js.txt)
 
Last edited by a moderator:

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,608
Reaction score
1,405
First Language
French
Primarily Uses
RMMV


Hi @Shaz


Awsome your script, is what i need :)


Di you have any idea or solution for me .


Am trying to do this.


◆Command:AddTimer Test<thismap> 5 \setss([<thismap>, <thisevent>, 'A'], false)


The \setss([<thismap>, <thisevent>, 'A'], false) Not seem work .


Also try add this.$gameMap.mapId
\setss([this.$gameMap.mapId, <thisevent>, 'A'], false)


If you have trick for me ?


Tank you
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,533
Reaction score
12,057
First Language
English
Primarily Uses
RMMV
this doesn't mean anything.  <thismap> means something, because I've made it mean something.


Can you please show a screenshot of your event?  Include the whole event window, and if it has multiple pages, show one screenshot for each page.
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,608
Reaction score
1,405
First Language
French
Primarily Uses
RMMV
ok 


I have this in my plugin


I add 
    $gameSwitches.setValue(13, true);
this appen eatch time player transfer map


Scene_Map.prototype.create = function() {
Scene_Base.prototype.create.call(this);
this._transfer = $gamePlayer.isTransferring();
var mapId = this._transfer ? $gamePlayer.newMapId() : $gameMap.mapId();
$gameSwitches.setValue(13, true);
DataManager.loadMapData(mapId);
};


The gameSwitch(13) will active one time this kind of event on eatch map.
And This event generate random ressource ( rock, grass, .... ) on the map load.


Rigthclik, open new windows for fullscreen


page1.jpg


This is the ◆Commande:GenerateMap


command === 'GenerateMap') {

for (g = 1; g <= MapNBMaxRock; g++) {
// mapid, eventid, regionid, respawn after map transfer (le random generete des modele aléatoir, voir map 0004)
//modele roche 1 a 6
$gameMap.copyEventFromMapToRegion(4, 1 + Math.floor(Math.random() * 6), 2, true);
console.log('G= ' + g);
}




After i want your time to maybe about 400 Second.
So ressource will never generate again, when player will come to this map, befor your timer finish.
When your time finish, if player enter in this map, il will generate random ressource again.
i dont know if your are understant


Sorry for poor english. :)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,533
Reaction score
12,057
First Language
English
Primarily Uses
RMMV
What's on tab 2 of that event?


Please change the plugin call to reference <thismap> rather than this.$gameMap.mapId - it won't work unless you do that.


Once we figure out what the problem is, there's another issue.  If the timer hasn't run out and the player comes back to this map, then the timer runs out while the player is ON the map, I think your event will run again, which means the map might regenerate while the player's on it.  Is that what's actually happening?  You said it doesn't work, but "doesn't work" could mean a lot of things - I just assumed you meant the self switch never turned off.


And, of course, you'll have to change the 5 to 400 to make it run after 400 seconds.
 
Last edited by a moderator:

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,608
Reaction score
1,405
First Language
French
Primarily Uses
RMMV
What's on tab 2 of that event?


Please change the plugin call to reference <thismap> rather than this.$gameMap.mapId - it won't work unless you do that.


Once we figure out what the problem is, there's another issue.  If the timer hasn't run out and the player comes back to this map, then the timer runs out while the player is ON the map, I think your event will run again, which means the map might regenerate while the player's on it.  Is that what's actually happening?  You said it doesn't work, but "doesn't work" could mean a lot of things - I just assumed you meant the self switch never turned off.
Tanks you @Shaz


i forget a parralele processe they close alway variable


now i can see is working good with


console.log($gameTimer._timers["GENROCK2"]);

timer runs out while the player is ON the map,


Nop because the game engine are JAP, and JAP read Left to right.
So the priority page are right [Page2].


But all work fine now is awesome tank you
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,533
Reaction score
12,057
First Language
English
Primarily Uses
RMMV
Uh - game engine being Japanese has nothing to do with it.  If both pages have conditions that are met, page 2 will have priority.  For ANY language version.
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,608
Reaction score
1,405
First Language
French
Primarily Uses
RMMV
Uh - game engine being Japanese has nothing to do with it.  If both pages have conditions that are met, page 2 will have priority.  For ANY language version.
yep but is not like this in unity , a american game engine 
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Guys I just want to sit around and work on my game! *gets lots and lots of money shoveled at him* Game, I don't recall a game. What game? :LZSexcite:
Seems like people have stopped looking both ways before crossing the road nowadays. Blindly walking out into a into a road only ends in disaster.
Just finished planning out the skeleton of the main quest line of my new game. I'm so excited for it!
Integrating Jason Perry's japan tile set while listening to Murray Atkinson's Heaven and Earth background music.
I forgot I had an account on rpgmakercentral lol

Forum statistics

Threads
94,544
Messages
921,771
Members
124,411
Latest member
yellowsonicboom64
Top