I have three variables to distinguish time; minutes, hours, and days. During the hours of 8 PM to 8 AM, I would like stores to be closed with a message letting the player know of the opening time of the store. How would I go about this?
Stores closed during night?
RPG Maker MV SupportThe player interacts with the "door" event that leads to the shop. Below are descriptions of what the Event Commands could be:
- Set a new variable (I'll call it variable #4 for this purpose) to be equal to the 'hours' variable.
- Multiply variable #4 by 60.
- Add the value of the 'minutes' variable to variable #4
- If variable #4 is less than 480 or greater than 1200, have the "door" event tell the player that the shop is closed. You can do this with a conditional branch to check the value of variable #4.
- Set variable #4 to zero (optional, but better to keep your "calculation" variables clean to avoid potential issues later)
This assumes that the value of the 'hours' variable at 8pm is 20 (i.e. uses a 24hr clock).
Yes, this could be done in a simpler way by only checking the 'hours' variable because the shops open exactly on the hour. However it is good to get used to this technique for shops that are open from 08:30 to 20:30, for example.
How would I utilize the conditional branch exactly? Since the hour is precise, this is referring to Note2.
An easier variant is to use variable condition instead of conditional branch, but this requires a single variable for time.
Make an event with three pages. Second page condition variable hours 8 or greater.
Third page condition variable hours 18 or greater.
First and third page "show text closed" or whatever you want to happen when the shop is closed.
Second page handles shop processing and will be active as long as the variable for hours is between 8 and 17.
Make an event with three pages. Second page condition variable hours 8 or greater.
Third page condition variable hours 18 or greater.
First and third page "show text closed" or whatever you want to happen when the shop is closed.
Second page handles shop processing and will be active as long as the variable for hours is between 8 and 17.
@Andar Worked like a charm, thank you!
Having multiple event pages like that is the perfect answer if you only need to look at 1 variable, it's easy to read and see what is happening.
If you need to look at more than 1 variable, then you have to get comfortable with variables and conditional branches. Here is an example of what I described before to have a shop open from 8:30am to 8:30pm:
Here's a graphical representation of the logic:
If you need to look at more than 1 variable, then you have to get comfortable with variables and conditional branches. Here is an example of what I described before to have a shop open from 8:30am to 8:30pm:
I could possibly use this in some of my later projects. 🙂 I appreciate the assistance. I'm keeping the visual representations as a reference for later on for other conditions I'll need.
Original thread: https://forums.rpgmakerweb.com/threads/stores-closed-during-night.92942/