How to make it so you can only enter a building during the day?

I've set up a day and night system in RPG maker mv on my switch (I know, I need to get an actual computer), but it works pretty well. I want to make it so that if a character tries to enter a shop at night or early morning, a message will appear and bar entry, and if they enter during the day time the transfer location function works normally. Here is my time system:
IMG_2578.JPG




here is the first page of the event that is supposed to take you to the inside of the shop:
IMG_2572.JPG


And here is the second page of that event:
IMG_2571.JPG

I'm pretty new to using this program and have just been following youtube tutorials, but I need some help! It lets me move into the building alright, but It won't display the message. any advice?
You would put the transfer command inside a conditional statement where you check either a variable range of allowable entry hours or check a switch that is toggled by it being night or day
What is this interface I am looking at 😳
Anyways, you need to define when "morning" or "night" is.
From a quick glance at your events, it seems like you set a clock for the day night, but you never defined when night is.
Let's create a new variable called "time of day"
We'll say that 0 is morning, 1 is day, and 2 is night.
Basically, set up a conditional in the loop for your timer to set the day/night:
if "time" is (equal to or greater than) [night time]
If "time" is < [day time]
Set "time of day" to 0

(new conditional)
If "time" is (equal to or greater than) [morning time]
If "time" is < [night time]
Set "timeOfDay" to 1

Then finally one more conditional
If "time" is > [day time]
Set "timeOfDay" to 2

This could also be cleaned up further, as it's a bit of a messy way of doing it. If each time of the day is exactly the same length of time, then you could use the mod of your time variable to define "timeOfDay".

Once you have defined time of day, you can now use that as a conditional on any and all shops. E.g. "If timeOfDay = 1, open! Else, closed."

You can also do this without the extra variable. Instead of defining a new variable, you already have the time variable used for your day night cycle. So in your head, just decide: "well when the time variable is within this range, that will be my morning, and when it's within this range it will be my day."
Then just set a conditional on the door "If time is great than this time. If time is less than this time. Open!"
This is useful for setting different open/close times for different shops. The first method creates an extra variable, but makes setting up open/close times easier.

P.s.
This forum doesn't offer support for the Switch version of RM. But eventing is eventing.
Do you have a day night system in place yet?
What is this interface I am looking at 😳
Anyways, you need to define when "morning" or "night" is.
From a quick glance at your events, it seems like you set a clock for the day night, but you never defined when night is.
Let's create a new variable called "time of day"
We'll say that 0 is morning, 1 is day, and 2 is night.
Basically, set up a conditional in the loop for your timer to set the day/night:
if "time" is (equal to or greater than) [night time]
If "time" is < [day time]
Set "time of day" to 0

(new conditional)
If "time" is (equal to or greater than) [morning time]
If "time" is < [night time]
Set "timeOfDay" to 1

Then finally one more conditional
If "time" is > [day time]
Set "timeOfDay" to 2

This could also be cleaned up further, as it's a bit of a messy way of doing it. If each time of the day is exactly the same length of time, then you could use the mod of your time variable to define "timeOfDay".

Once you have defined time of day, you can now use that as a conditional on any and all shops. E.g. "If timeOfDay = 1, open! Else, closed."

You can also do this without the extra variable. Instead of defining a new variable, you already have the time variable used for your day night cycle. So in your head, just decide: "well when the time variable is within this range, that will be my morning, and when it's within this range it will be my day."
Then just set a conditional on the door "If time is great than this time. If time is less than this time. Open!"
This is useful for setting different open/close times for different shops. The first method creates an extra variable, but makes setting up open/close times easier.

P.s.
This forum doesn't offer support for the Switch version of RM. But eventing is eventing.
Yeah, someone else just informed me that this forum doesn't offer support for the switch version, my bad, I'm a newbie lol! first of all thank u for ur help!! this was a really good explanation especially for someone who is pretty awful at the more technical stuff of RPG maker.
It allowed me to enter the building, so partial success! it just won't display the text sadly. It's really not that necessary, it's more of a matter of pride at this point/figuring out what I'm doing wrong so I can learn from this mistake. Is this correct? Creating a common event that defines the different times of day?
IMG_2585.JPG

This is what I used for the event - is it possible that the trigger being "player touch" isn't compatible with showing text? I'm just confused as to why I can move inside the building yet the text refuses to show up. Thank you so much again for your time and help!!
IMG_2584.JPG
Do you have a day night system in place yet?
Yes, it's the first image I uploaded 🙂
Well firstly, you have the the condition of the time of day variable nested within another time of day variable.
Your second screen shot shows:
Code:
"If Time of Day = 0
   If Time of Day = 2"
This basically means, "If the time of day is 0 AND the time of day is 2, do this." Which is obviously a bit of a paradox since it can't be 2 different times of day at once. This isn't quantum RPG making.

So, first, you should separate your conditionals.
Code:
"If time of Day = 0"
Do this.
"If time of Day = 2"
Do this.

Secondly, you can simplify this a little bit. Logically, it makes sense to have 0 = morning, 1 = day, 2 = night. But since morning and night are effectively doing the same thing for your shop (making it closed), I would maybe make 0 = day, and then 1 and 2 would be morning and night respectively. (I know this contradicts what I said in my post before)
This is because you can use just 1 conditional by using a greater than check and an else branch.
So:
Code:
if time of day is greater than 0
shop's closed!
else
shop is open!

Thirdly, it should not be on a new common event. This logic can be contained within your existing time logic common event. Put the Time of Day logic under your "if hours" conditional in the Time_Counting common event.



This could be simplified even further. When I made my original post, I didn't realize you were already tracking hours (sorry, I was on my phone and was too lazy to zoom in on the pictures).
Since you are incrementing hours you could just check your shop using your existing hours variable instead of creating a new one. The "Time of day" method simplifies things a lot, but it does create an additional variable. If you want to simplify your used variables, then on the shop door, put a conditional check for the hours within a range.
So for example:
Code:
If hours (equal to or greater than) 0
  If hours is < 9
  Shop is closed.
If hours (equal to or greater than) 20
  Shop is closed.
If hours (equal to or greater than) 9
  if hours < 20
  Shop is opened!

This method completely removes the necessity of the "time of day" variable and all the logic associated with it. I'm not familiar with the Nintendo Switch version, if you don't have access to a copy-paste function on the Switch, this might be a hassle to have to set up for every shop. In which case, your have 2 options:
1) Move the above logic into a common event, and don't have it be a parallel common event. On every shop door event, attach this common event to it. On activation of the door, this common event will run and make that check. (this is also kind of best practice anyways, because if later down the road you decide to change the shop hours, you don't need to change the hours for EVERY shop in your game, you only need to change the 1 common event)
2) The previous "Time of Day" method mentioned is easier to set up and might be quicker to do if you don't have a copy-paste function.

edit:
pressing "save" removed all my formatting ;_;. I fixed it now.
Fixed a mistake in my logic and clarified a few things so my post reads more clearly.
Well firstly, you have the the condition of the time of day variable nested within another time of day variable.
Your second screen shot shows:
Code:
"If Time of Day = 0
   If Time of Day = 2"
This basically means, "If the time of day is 0 AND the time of day is 2, do this." Which is obviously a bit of a paradox since it can't be 2 different times of day at once. This isn't quantum RPG making.

So, first, you should separate your conditionals.
Code:
"If time of Day = 0"
Do this.
"If time of Day = 2"
Do this.

Secondly, you can simplify this a little bit. Logically, it makes sense to have 0 = morning, 1 = day, 2 = night. But since morning and night are effectively doing the same thing for your shop (making it closed), I would maybe make 0 = day, and then 1 and 2 would be morning and night respectively. (I know this contradicts what I said in my post before)
This is because you can use just 1 conditional by using a greater than check and an else branch.
So:
Code:
if time of day is greater than 0
shop's closed!
else
shop is open!

Thirdly, it should not be on a new common event. This logic can be contained within your existing time logic common event. Put the Time of Day logic under your "if hours" conditional in the Time_Counting common event.



This could be simplified even further. When I made my original post, I didn't realize you were already tracking hours (sorry, I was on my phone and was too lazy to zoom in on the pictures).
Since you are incrementing hours you could just check your shop using your existing hours variable instead of creating a new one. The "Time of day" method simplifies things a lot, but it does create an additional variable. If you want to simplify your used variables, then on the shop door, put a conditional check for the hours within a range.
So for example:
Code:
If hours (equal to or greater than) 0
  If hours is < 9
  Shop is closed.
If hours (equal to or greater than) 20
  Shop is closed.
If hours (equal to or greater than) 9
  if hours (equal to or less than) 20
  Shop is opened!

This method completely removes the necessity of the "time of day" variable and all the logic associated with it. I'm not familiar with the switch version, if you don't have access to a copy-paste function on the switch, this might be a hassle to have to set up for every shop. In which case, your have 2 options:
1) Move the above logic into a common event, and don't have it be a parallel common event. On every shop door event, attach this common event to it. On activation of the door, this common event will run and make that check. (this is also kind of best practice anyways, because if later down the road you decide to change the shop hours, you don't need to change the hours for EVERY shop in your game, you only need to change the 1 common event)
2) The previous "Time of Day" method mentioned is easier to set up and might be quicker to do if you don't have a copy-paste function.

edit:
pressing "save" removed all my formatting ;_;. I fixed it now.
Oh my gosh, thank you SO SO SO MUCH i have no words to express my gratitude. I did everything you said and now the text displays and I’m able to move into the building at the designated times. Thank u for the extremely detailed explanation 🙂)
No problem.
I also adjusted the logic in my previous post as there was a small mistake. I had it set to if equal to or greater than hour 20: shop is closed, but I also had if equal to or less than hour 20: shop is open. That second if (for the open shop) should be just "less than" (<) not "equal to or less than".
It wouldn't cause any major problems with the event, but would just result in shops being open an hour longer than expected.



Always glad to be able to help. It's worth mentioning that, since this Forum is an official RPG Maker forum, but is not the official forum for the Switch version (as the console versions are published by another company) I am not sure if we are really allowed to offer help. The rules get screwy with the spin off RM titles here and I'm not 100% sure. Maybe mods can clarify. @Shaz or @Ms Littlefish
Regardless, the main take away here, whether or not it is allowed, is that most everyone here is going to have trouble troubleshooting or providing support since most of us don't own the software on the Switch. There may be differences between the Switch version and the PC version that we are not familiar with; either in terms of functionality or in terms of technical stuff under the hood. Basic eventing stuff like what I provided you is pretty universal across the entirety of the RPG Maker series (afaik) so it's easy to provide a basic "best practices" for that kind of stuff, but the actual operation could differ (even if slightly) from the PC version.

I definitely recommend investing in the PC version if you enjoy the taste of what you experience on the console. On the PC version you have access to way more resources - many provided by our great staff here, such as Avery. You also have access to deploying the game for anyone and everyone to try, whereas on the Switch I think distribution of whatever games you make is very limited (as in, maybe only friends and family will be able to play your game). You also have access to the vast 3rd party developed additional functionality added by plugins, which can improve the game and add many cool new features to help create something truly unique. Finally, you also have access to the backend of your game project, which will allow for updating backend software (such as NWJS or PIXI - the graphics renderer), and the core scripts, and for the real lunatics out there, hooking Middleware into the game like this guy's insane ambition to hook fmod into RM (guy is nuts).
So, spend some time learning the basics of eventing in RPG Maker, and if you enjoy what you experience, come on over to the Glorious PC Master Race side and bask in the glow of a modern engine that still produces games that look like they released in the 90s.
So pretty much if it’s not sold in the Komodo store, we don’t support it on this forum since it’s Komodo’s. By that logic, I’d assume seeing how the storefront only has the PC and Steam version of MV that the Switch one is a no-go.

I approved the thread so…oops. I’m a simple lady. Not gonna lie. This is what you get from me when I skim and read the forums without my glasses. My B.

Anyway, I think the PC/Steam version is on sale if you wanna join us here full time! 🙂
Moderator note: Gonna close this now

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-it-so-you-can-only-enter-a-building-during-the-day.158320/