Creating an Event That Resets Based on Time

Okay, I'm trying to make a couple of events that happen an infinite amount of time, but have a "Cool Down" period if you will. For example: There is a maid that will cook you a meal that will restore MP for your party. However, she can only cook one meal every half hour. I know I'll need a script for this, and I've already gotten shaz's Extended Timer Functionality script. I'm absolutely useless with scripts, and I don't understand the posted directions. I've tried reading them and messing around on my own, but I still can't make it work without either crashing the game or the event simply not working. If someone can help I would greatly appreciate it.

I'll include screenshots of what I'm doing, and what's going wrong.

Untitled.png

Untitled2.png

Untitled3.png
First of all, I wouldn't be using a self switch, you should be toggling a reg switch.

As for the error, It's pretty obvious what's wrong, you made a mistake in your scripts, I don't know this script, so I can't tell you how It's suppose to be written, but yea It's wrong, so I would research how to write timer scripts in Ruby again.

Also you'll want a condition branch to turn off the switch after the time is up(well in script anyway, since the reason why you're using a script for this, is so you don't see a timer, so use the script option in condition branch settings)

PS. If you can't figure out how to script this, I just figured how to do this without a script or a big timer on the screen. First you'll want to set a variable(Game data/play time) when she makes your meal, and turn on a switch. Then on the next page make a condition branch using the play time variable, greater then a hour, turn off switch, done.
I think there's already a script out there that let's you "respawn" events after a set time. It might work for you
@Zoltor: I know I'm going to sound dumb for asking, but what's 'Ruby'?

@Engr.Shana: Do you know what the script would be called, or where I could download it?

I haven't gotten a chance to work on my project since I posted this thread because of school, but do you think it would be possible to somehow tie amount of experience gained to the event as opposed to time? Because for other events where I would want a longer time before it re spawns it would suck if you have to wait several hours, especially if you're trying for a low completion time or just don't want to wait that long...
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.

You should always provide a link to the script you're using, to make it easy for people to look it up and help you. You could also have just posted in that thread and asked for help with the correct way to call it, posted your screenshots, and I would have helped you out 😉

Extended Game Timers

Your second page is wrong. But the script call is ALMOST right on the first page. You are passing the wrong parameters through to the script. And you have a few other issues with your event. You need to pass the map NUMBER, not the NAME. And don't put leadings zeros. I can't see your map number, but let's assume it's 23. Your event number is 13, and you want self switch A turned ON when she cooks for you, then OFF after half an hour so she'll cook again.

So on tab 1, where she cooks for you, put the following:

Script: $game_timer.set_timer(30, [@map_id, @event_id, 'A'], false)Control Self Switches: A = ONOn tab 2, change it back to action button, get rid of the script, and put in whatever you want to happen when you talk to her when she's NOT ready to cook something for you.[@map_id, @event_id, 'A'] says to modify self switch A of the current event on the current map. This is good to use if you want to duplicate the same event several times - you don't have to go in and change the map and event numbers on each of them. You could also have written this:

Code:
Script: $game_timer.set_timer(30, [23, 13, 'A'], false)
And if it doesn't all fit on a single line, you're correct in putting the line break after a comma, or you could also put it after ( or [
@Zoltor: I know I'm going to sound dumb for asking, but what's 'Ruby'?

@Engr.Shana: Do you know what the script would be called, or where I could download it?

I haven't gotten a chance to work on my project since I posted this thread because of school, but do you think it would be possible to somehow tie amount of experience gained to the event as opposed to time? Because for other events where I would want a longer time before it re spawns it would suck if you have to wait several hours, especially if you're trying for a low completion time or just don't want to wait that long...
Ruby is just another name for the RGSS script that RPG Maker uses.
Ruby is the language where RGSS was based on...
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.

You should always provide a link to the script you're using, to make it easy for people to look it up and help you. You could also have just posted in that thread and asked for help with the correct way to call it, posted your screenshots, and I would have helped you out 😉

Extended Game Timers

Your second page is wrong. But the script call is ALMOST right on the first page. You are passing the wrong parameters through to the script. And you have a few other issues with your event. You need to pass the map NUMBER, not the NAME. And don't put leadings zeros. I can't see your map number, but let's assume it's 23. Your event number is 13, and you want self switch A turned ON when she cooks for you, then OFF after half an hour so she'll cook again.

So on tab 1, where she cooks for you, put the following:

Script: $game_system.set_timer(30, [@map_id, @event_id, 'A'], false)Control Self Switches: A = ONOn tab 2, change it back to action button, get rid of the script, and put in whatever you want to happen when you talk to her when she's NOT ready to cook something for you.[@map_id, @event_id, 'A'] says to modify self switch A of the current event on the current map. This is good to use if you want to duplicate the same event several times - you don't have to go in and change the map and event numbers on each of them. You could also have written this:

Script: $game_system.set_timer(30, [23, 13, 'A'], false)And if it doesn't all fit on a single line, you're correct in putting the line break after a comma, or you could also put it after ( or [
I tried typing in the code like you demonstrated Shaz, with one minor change. I made the 30 (Which I assumed was the time the event would occur in) to 1 for quick testing purposes. My event ID was 13, and the map ID 21. I'm still getting error reports though, I'll post screenshots of what I was doing.

page1.JPG

page2.JPG

Untitled.jpg
In the first screenshot's script call, you don't close the parentheses....
Okay... Thank you for pointing that out, otherwise I would've never solved it... but I'm still getting an error message, this time though it's one that makes absolutely no sense to me. 

And I'd just like to say, thank you everyone who's still helping me, I feel like I'm wasting your time and I don't want to be bothersome. 

pic1.JPG

pic2.JPG
Well, Shaz' instruction for her own script above is slightly wrong. It should not be 

$game_system.set_timerthe correct script call is

$game_timer.set_timerChange the $game_system in your event to $game_timer, and you'll do fine.

Edit: It seems that you change an event's self self switch. It will be more accurate to use

$game_timer.set_timer(1, [@map_id, @event_id, "A"], false)This way, when you copy the event elsewhere, you don't need to change the script call, as @map_id and @event_id are set automatically to the current map and current event ID.
ERMERGERD! It works, thank you so much! I'll be using this to program a whole bunch of events and stuff now, yay!

Could one of the moderators close this post now?
Thank you ShadowLurk. I am getting myself confused with an older version of the script (which I am actually still using in my own project) and got the call wrong. I appreciate you taking the time to figure out what was wrong and correcting me. I've fixed the original post (at least the instructions on the script page are right 🙂 )


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/creating-an-event-that-resets-based-on-time.24417/