How do I wait in game?

In the pics below I have a simple test event that is going to be used for things like gathering herbs or chopping down trees.
Page 1 is for the unharvested event and page 2 is for the harvested event.
The problem I am having now is that I need a respawn time of 10 minutes or so.
I did find a way using the timer and a conditional branch to set respawn time to 10 minutes.
Worked fine but then I noticed the timer was visible.. lol
I am always needing a way to wait long periods of time so any help will help way beyond this event.
Any advice would be great. Thanks!
Create a variable "Timer"
At the start of the event, set the variable to 600.
Then create a loop (using the create loop event command)
Subtract 1 from the Timer variable, then set a 60 frame (1 second) wait.
Set a conditional "if Timer is equal to or less than 0"
Set self switch accordingly, break loop.

Edit:
I'm on my phone, can't do screen shots. If my description is unclear, I can post screen shots later.
Also, this loop obviously should be inside a parallel event, just to be clear.
another small edit, changed the order of the loop break and self switch.
Create a variable "Timer"
At the start of the event, set the variable to 600.
Then create a loop (using the create loop event command)
Subtract 1 from the Timer variable, then set a 60 frame (1 second) wait.
Set a conditional "if Timer is equal to or less than 0"
Break loop, set self switch accordingly.

Edit:
I'm on my phone, can't do screen shots. If my description is unclear, I can post screen shots later.
Also, this loop obviously should be inside a parallel event, just to be clear.
Thanks a lot! This is going to help me a lot with all kinds of stuff.
If you post a screen shot that would be great. I have been playing with this for 2 hours
and still can't get everything working right. 😛
Thanks a lot! This is going to help me a lot with all kinds of stuff.
If you post a screen shot that would be great. I have been playing with this for 2 hours
and still can't get everything working right. 😛
I'm on MZ righ now, here's what @TheAM-Dol meant
1675303736602.png
I'm on MZ righ now, here's what @TheAM-Dol meant
There are some issues with that event.

1 - I don't see what the point is of having a variable and the wait command and a loop. Why not just set a number of waits equal to the total time you want to count down?

2 - This is in a map event, so if the player left the map it would stop running and break the respawn timer. However...

3 - Because you made it an Action Button trigger, and not a Parallel event as @TheAM-Dol said, the Wait command prevents the player from moving. So this is going to essentially freeze the game for 10 minutes.

What @gamingfamilyman should do is on page 1 of his event set a game switch instead of a self switch. Have nothing on page 2.

Make a parallel common event triggered by that switch that has Wait commands adding up to 6,000 (because they're in a parallel event they'll make it wait for the next event command but not stop the player input), then turn the switch back off.

That will stop the parallel event and put the map event back to its first page.

If you have multiple/many of these harvesting nodes in your game and you don't want to waste lots of switches and parallel events, you can check out a more advanced technique with this tutorial from @Trihan:
I'm on MZ righ now, here's what @TheAM-Dol meant
View attachment 252227
Thanks. I have close to that setup going but my main hang up right now is getting page 2 to
go back to page 1 after page 2 has finished. This is because of the images.
Making 2 pages is the only way I know how to change an events image.
If you do go with an approach like my tutorial let me know if you run into any issues with it and I'll be more than happy to help you through them.
Thanks. I have close to that setup going but my main hang up right now is getting page 2 to
go back to page 1 after page 2 has finished. This is because of the images.
Making 2 pages is the only way I know how to change an events image.
Make sure you read my post. You would make it go back to page 1 by making the condition for page 2 not be fulfilled anymore - simply turn self switch A back off.

But putting your timer on the event on the map is not a good way to go, even if it's parallel and doesn't freeze the game - it will break as soon as the player leaves.
Thanks. I have close to that setup going but my main hang up right now is getting page 2 to
go back to page 1 after page 2 has finished. This is because of the images.
Making 2 pages is the only way I know how to change an events image.
Just turn the self switch A off. This should be enough.

as for the problems @ATT_Turan mentioned, number 3 is my bad, I didn't set the trigger correctly since I only focused on the commands. Should have noted that.

If OP wants the event to be running in all maps, using the common event method you suggested will solve the issue.

If he wants the countdown to stop if the player leaves the area (for whatever reason), this wiill suffice:
1675306823997.png



As for my personal suggestion, the method @Trihan posted is the best way to go with this system. It is the method I'm using currently and has been working perfectly.
If you do go with an approach like my tutorial let me know if you run into any issues with it and I'll be more than happy to help you through them.
Thanks for the offer! I was going to try it in the morning but after one final try before bed I got it!
I'm sure it isn't as good as your method but I should sleep well now. 🙂
Make sure you read my post. You would make it go back to page 1 by making the condition for page 2 not be fulfilled anymore - simply turn self switch A back off.

But putting your timer on the event on the map is not a good way to go, even if it's parallel and doesn't freeze the game - it will break as soon as the player leaves.
Thanks. I did read it! I was worried about having the event tied to the map so this will help.
I got it working finally but only on the map so I'm going to try to use common events instead.
The problem I see now is how I would get the images to work out. I will try it in the morning.
Should begin to make since after a cup of coffee! I had to force my self to turn it off just now lol.
Here an Example, maybe it helps?

You need 1 Variable for each Mining Note Event.
Than 1 Parallel Event that checks if one of the dozen Mining Notes on this Map need to respawn.

miningnote01.png

MiningNote02.png

minignote03.png


Edit:
The good thing is: You can harvest the Note, leave the Map, Play for Hours, no code need to be running in background, and when you come back, the timestamp will do the magic.
I don't see what the point is of having a variable and the wait command and a loop. Why not just set a number of waits equal to the total time you want to count down?
Come to think of it...me either 😛 I'm not sure why I started doing timers like that, I think there was a reason though :LZSskeptic:
Anyways, thanks for correcting it!
I'm not sure why I started doing timers like that, I think there was a reason though
I mean, it doesn't hurt anything! But between using the game variable and just the number of event lines taken up, it's a bit less efficient.

Bex's method of using the timestamp absolutely works - just be leery that implementing it exactly as shown takes up a game variable for every single harvesting node. Using Trihan's method involves some JavaScript but puts all nodes in your game into one variable as an array, which makes the rest of your project much cleaner.

For my tastes, I would modify Trihan's method to be measured in seconds and add a Wait 60 to the end of the parallel event, just as good practice. It shouldn't create any adverse effects with how little it's doing, but...like, why not? I can't imagine anyone needs their harvesting respawns to be punctual to the frame.
I mean, it doesn't hurt anything! But between using the game variable and just the number of event lines taken up, it's a bit less efficient.

Bex's method of using the timestamp absolutely works - just be leery that implementing it exactly as shown takes up a game variable for every single harvesting node. Using Trihan's method involves some JavaScript but puts all nodes in your game into one variable as an array, which makes the rest of your project much cleaner.

For my tastes, I would modify Trihan's method to be measured in seconds and add a Wait 60 to the end of the parallel event, just as good practice. It shouldn't create any adverse effects with how little it's doing, but...like, why not? I can't imagine anyone needs their harvesting respawns to be punctual to the frame.
Yeah, honestly I just do it that way through force of habit of implementing timers in frames because I usually do it on the Javascript side where that's how it needs to be done. Your edit probably makes sense for something being done in the editor.
It took me an hour but i improoved the Event and shortened it.

Variable 500 to 1000 are for your or Notes Gamewide.
Just use one of the Variables as Eventpage Condition for the 2nd Page of a Mining Note.
And set the Timer on the 1st Page.
The Parallel Event in this case is finished and does not need Editing, all 500 Timers are done.
neworenote01.png

neworenote02.png

neworenote03.png


I hope this helps you to have fun with Mining.
Notes:
  • Parallel events stop/restart on map change, e.g. a single Wait 600 frames Parallel common event could go on forever if you never spent that long on any single map. Therefore it is better practise to use smaller waits with a variable counter, unless in a situation where map changes cannot happen (e.g. "escape before the room explodes").

  • Be careful using the playtime as a timestamp: by default that increases every second of the playthrough, including battles and menus.
As mentioned, you'd need one variable per timer. A "self variables" or "self timers" kind of plugin may help to streamline that, so you can avoid the need for 1 game variable slot per timer. Or you could follow Trihan's tutorial and store all timers in 1 game variable.

For a pure-event solution I'd suggest you set the variable in one event, to initialise the timer. Then have a separate, Parallel event to handle the timer's progression in the background. No need for Loop/Break Loop because active Parallels automatically trigger every frame that they're not currently running.

I gave some full event examples in this thread, though it includes extra stuff: the "timer" is actually a step counter and only progresses if the current step count has changed. Might be helpful, though~
If you do go with an approach like my tutorial let me know if you run into any issues with it and I'll be more than happy to help you through them.
Okay new day! I am wanting to understand how programming works in MZ.
I have programmed some simple text/console based rpgs so I do understand some basics.
I have never programmed outside of a console though and didn't know you could put script
into the event editor like I saw you did.
What is the best source I could use to learn as a beginner?
I have never used JS before so hoping its syntax is easy to read.
I only plan to script in the event editor also. I don't plan to do any plug ins any time soon.
Okay new day! I am wanting to understand how programming works in MZ.
I have programmed some simple text/console based rpgs so I do understand some basics.
I have never programmed outside of a console though and didn't know you could put script
into the event editor like I saw you did.
What is the best source I could use to learn as a beginner?
I have never used JS before so hoping its syntax is easy to read.
I only plan to script in the event editor also. I don't plan to do any plug ins any time soon.
For learning Javascript I'd recommend w3schools, codecademy and freecodecamp. They all have some robust and informative Javascript courses that'll teach you the basics and some of the advanced stuff.
Okay new day! I am wanting to understand how programming works in MZ.
I have never used JS before so hoping its syntax is easy to read.
I second Trihan's suggestions.

I'll also add - you can really accomplish a lot in RPG Maker without having to learn to code. Between the event system, plugins, and throwing in the occasional isolated script call, it's very versatile.

By all means, do some JavaScript tutorials, but I would suggest that something like Trihan's respawning tutorial that I linked you to is probably more advanced than you need to understand for most stuff you'd want to put in your game.

If there is a specific thing you need to do, the pinned Script Call list can help you achieve a lot without getting into any more complicated code. For example, the function to look at the self-switches of a different event has made my game way more efficient than it might be otherwise.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-wait-in-game.154599/