Day/Night Evented System
Ok, this is a fairly simple, but very effective system. It only requires two variables and two switches, unless you decide to add days, weeks, years, or AM/PM. Right now, it runs on a 24 hour system, so 1:00PM is 13:00. It can be done entirely in the common event page of the database. What's more, I'll include another event system under this one (same page) that can play music for day and night in individual places.
So let's get to it! I'll go through it in steps.
1. Go to the common event page under the database and make a new common event called "Clock," or "Time," or whatever you wanna name it. For the purpose of this tutorial, we'll call it "Clock." Make the trigger a parallel process, run by a switch, which we'll call "TIME."
2. Start a loop. This loop will never break. Ever.
3. Make a conditional branch. This is where your first variable comes in. Make the conditional branch state that if Hours is less than 6, it'll do... the next step.
Your code should look like this...
4. Inside this statement, control a switch called Night to the ON position. Then tint the screen to RGB: -128, -96, -64, and a grey of 128, making it take 600 frames, and do NOT wait for completion.
5. Copy and paste this entire branch into the else statement of the branch. Change the parameters of the branch to hours > 20. It should look like this...
6. In the else statement of THAT branch, control the switch Night to be OFF, then tint the screen back to normal, with the frame time at 600, and do not wait for completion.
Spoiler for :
@>Loop @>Conditional Branch: Variable [0001:Hours] < 6 @>Control Switches: [0001:Night] = ON @>Tint Screen: (-128,-96,-64,128), @600 @> : Else @>Conditional Branch: Variable [0001:Hours] > 20 @>Control Switches: [0001:Night] = ON @>Tint Screen: (-128,-96,-64,128), @600 @> : Else @>Control Switches: [0001:Night] = OFF @>Tint Screen: (0,0,0,0), @600 @> : Branch End @> : Branch End : Repeat Above
I won't copy and paste the whole code now, but everything must now be written after what you have already written.
7. So, after everything except for the loop end, you want to write the code to move time forward. To start, wait 60 frames. That's one second. Then change a variable named "Minutes" to +=1. It should look like this...
8. Now that you have that, create a conditional branch that checks if the minutes are equal to 60. Don't bother setting handling when conditions don't apply. In this, set the minutes to 0, and the hours to += 1. It'll look like this...
9. Now, copy and paste that branch under itself. Change the parameters so that it checks if hours are equal to 24. Erase the change in the minutes, then make it so that the hours are set to 0, rather than += 1.
10. You're done! That's it! Set the variables "Minutes" and "Hours" to whatever you want in a separate event, and you have your day/night system! If you ever want to turn off the clock for a specific event, you can do that by turning off the "TIME" switch we made at the start. Just to be specific, I'll post the code below to show you what it looks like, then I'll resume the tutorial with a few new quirks and tricks.
Spoiler for :
@>Loop @>Conditional Branch: Variable [0001:Hours] < 6 @>Control Switches: [0001:Night] = ON @>Tint Screen: (-128,-96,-64,128), @600 @> : Else @>Conditional Branch: Variable [0001:Hours] > 20 @>Control Switches: [0001:Night] = ON @>Tint Screen: (-128,-96,-64,128), @600 @> : Else @>Control Switches: [0001:Night] = OFF @>Tint Screen: (0,0,0,0), @600 @> : Branch End @> : Branch End @>Wait: 60 frame(s) @>Control Variables: [0002:Minutes] += 1 @>Conditional Branch: Variable [0002:Minutes] == 60 @>Control Variables: [0002:Minutes] = 0 @>Control Variables: [0001:Hours] += 1 @> : Branch End @>Conditional Branch: Variable [0002:Hours] == 24 @>Control Variables: [0001:Hours] = 0 @> : Branch End : Repeat Above
So, there are a few things that you can do with this system to make it even better. I'll provide a list of them and how to make them all work really well.
1. The Inn
This is really easy. Basically, whenever you visit an Inn or sleep, it'll change the time from day to night, or night to day. How do you do this? Just add a bit of code to your sleep events. Here's what a basic Inn should look like with this system...
Spoiler for :
@>Text: -, -, Normal, Bottom : : 1000 Gold for one night. Would you like to stay?\G @>Show Choices:, Yes, No : When [Yes] @>Conditional Branch: Gold 1000 or more @>Change Gold: -1000 @>Fadeout Screen @>Play ME: 'Inn', 100, 100 @>Conditional Branch: Switch [0001:Night] == ON @>Control Switches: [0001:Night] = OFF @>Control Variables: [0001:Hours] = 8 : Else @>Control Switches: [0001:Night] = ON @>Control Variables: [0001:Hours] = 20 @> : Branch End @>Wait: 300 frame(s) @>Recover All: Entire Party @>Fadein Screen @> : Else @>Text: -, -, Normal, Bottom : : You don't have enough money. @> : Branch End @> : When [No] @> : Branch End @>
2. Day/Night Music
This is a really neat effect you can do with whatever maps you want. It basically changes the music of a certain area depending on what time it is. The best way to do this is to place the event in each map, with whatever music you want in each place. This only works well if the default map BGM is set to nothing, and if done in a parallel process. Here's a very basic way to do this.
3. The Pocket Watch
Just as it says. An item accessible through your inventory or main menu that tells you the time. Just bond an item to a common event called "Pocket Watch." Then put this code in that event.
Spoiler for :
@>Conditional Branch: Variable [0002:Minutes] < 10 @>Conditional Branch: Variable [0001:Hours] < 10 @>Text: -, -, Dark, Bottom : :Time: 0\v[1]:0\v[2] @> : Else @>Text: -, -, Dark, Bottom : :Time: \v[1]:0\v[2] @> : Branch End @> : Else @>Conditional Branch: Variable [0001:Hours] < 10 @>Text: -, -, Dark, Bottom : :Time: 0\v[1]:\v[2] @> : Else @>Text: -, -, Dark, Bottom : :Time: \v[1]:\v[2] @> : Branch End @>
4. We're Closed
You know how stores and houses are always open at all times of the day? Well guess what? Not any more. You can make any door lock itself at night with one extra page per event. You can even make certain people say different things, or make certain events happen at certain times. However, keeping with the interest of time, I'll just use the locked door code here.
Well, there isn't any code, but there is a trick.
Just add an event page at the very end of all the other pages for doors or people. The conditional switch should be (of course) Night. Now make a text that says, "We're closed for the night" or something like that. For people, you can make them say something different at night. If you really wanna be specific, you can make the condition a variable, so they say something at a certain time, but that's... well, not a whole lot more difficult, to be honest.
Well! That's everything! I hope someone gets use out of this, it works really well so far. If anyone finds any bugs, let me know.
Here's a demo.
http://www.megaupload.com/?d=XHD3ME7D I'd really appreciate credit for this one. This had the most work put into it.