Gw Temp


Tutorial - 'Day and Night using Timers' by Tull

An item about RPGMaker 2000 posted on


Another day and night tutorial, this time by Tull. It's his first tutorial, be sure to give him some constructive criticism.


Day and Night using the Timer

Tull here everyone. This is my first tutorial, and it came about after I wanted to make a Day and Night system for my game.
The other day and night tutorials didn't work with my game, so I had to come up with my own system. After reading one
tutorial, with used the Timer Operations, I realized how I'd underestimated them. So, inspired by that tutorial, I knew
how to model my day and night system around my game.

NOTE: the xxxx in Switches and Variables is no number. Because I don't think you'll use the same switches and variable
numbers as I will.

1. The Main Event; Day and Night cycling.

Switches and Variables needed:

Possible [xxxx]Timestart

That's all! Now for the coding;

You'll need a Common Event for this, which is the last tab in the Database. Choose an empty slot and name it
'Daytime' or something like that. Set it to Parallel Process and it's Start condition to Switch [xxxx]Daytime.
In the Event Commands box, start with a Fork Condition, located in the 3rd tab. Highlight the 'Timer' bit
in the box that'll pop up and set the Mins to 0 and the Seconds to 1 and 'Below'. Don't bother with 'Else'
case. Now, inside the Fork Condition (In between the Fork Optn and End Case), put in the command
'Set Screen Tone' (2nd Tab) and move the sliders so it's 0 0 0 100, put 20 in (2 seconds) and check the
'Wait' box. OPTIONAL: You can change the Parallex BG to 'Night' if you want.
Now put in the command 'Create Timer' (1st tab) and set the time to how long you want a day or
night to last. Then, Change Switch [xxxx]Nighttime ON, put in another timer operation, this time
'Start' You should leave the bottom two boxes unchecked. Now Change Switch [xxxx]Daytime OFF
and Wait for 2 seconds. Then set the screen tone to a good Night time colour. That's all for the Daytime
to Nighttime transition. I should explain why I had the screen go dark, do all the Day-Night stuff
and then, change the screen tone to Night-time. If you're in a town, and in your game, some people
are out only during Day or Night, you don't want them suddenly disappearing, do you? As soon as the
'Night' or 'Day' switch goes on, they'll disappear. But if your screen is dark, you won't see it, and it'll
make more sense.

Now, for Night to Day, If you're abit lazy, which I am sometimes (why ignore shortcuts?!) Copy the
Common Event 'Daytime' and Paste it into a new slot and re-name it 'Nighttime' or something like
that. Change the event start condition to Switch [xxxx]Nighttime. Leave the Fork Condition
as it is, in fact, the only things you have to change, is Replace [xxxx]Nighttime ON with [xxxx]Daytime
ON and [xxxx]Daytime OFF with [xxxx]Nighttime OFF. Then change the last screen tone to your
normal day one, which is 100 100 100 100 by default.

And that's your MAIN script! But you'll want to spark it, so, on the first Map you control your hero,
if you're doing a cutscene, which I'm doing in my game, program it at the very bottom, JUST before the
cutscene ends. If you're not doing a cutscene, just create a new event, no graphics, event start condition
set to 'Auto Start'. Now, do the following in your Event, to spark off the main event.
Set the Timer Operations (1st tab, you should be used to it by now) to how long you want each part
of the day to last. Then start the timer, as before. Change switch [xxxx]Daytime ON and if you're not
implimenting it into a cutscene where a switch or something will end it, Change Switch [xxxx]Timestart
ON. Now, create in that Blank event a new page (remember, only if you're not putting this into a cutscene)
Set the Start Conditions to Switch [xxxx]Timestart ON and the Event start condition to 'Push Key'. leave
the commands blank. Once you're done, that's started the whole Day-Night and Night-Day event
so you won't have to worry about it anymore.

But we have a problem. If you go Inside somewhere, like a house or shop, you'd expect the lighting to be
normal, but if it's nighttime, it'll be the same colour as the nighttime screen tone. Some much for lights....
but you can fix it. Create an new event, Paralell Process, no graphics. Set screen tone 100 100 100 100
0 seconds, uncheck Wait until done. Copy that event into each map that's a house or shop with lights.

Now, if you go outside, unless it's a fluke, and at that time, it's time for a screentone change
if it's night, the screen'll still be 100 100 100 100. So much for nighttime darkness. So,
go into Common Events, create an event called Outdoors, set it to Call. As the command,
Fork option, If Switch [xxxx]Daytime ON, Screen tone = 100 100 100 100.
Add another, NOT INSIDE THE LAST ONE Fork Option, If Switch [xxxx]Nighttime On,
Screen tone = Your nighttimet one. Now, everytime you're gonna teleport outside from inside, before the teleport
command, Call Event (3rd Tab) Outdoors, and that'll set the screen tone right :D

That's the tutorial, BUT, there's some optional stuff further down.


Switches and Variables Needed:



You may wanna know how much time there is before 'Daybreak' or 'Nightfall'. You should do this with an Item,
call it 'Clock' and set it to a 'Switch', 0 Price and Unlimited use. Set the 'Switch' to [xxxx]Calltimeuntil. Make
it only available in the field. That's the item sorted, go back to your Common Events. Create a new one called
'Time Until', set it to Autostart and start condition to [xxxx]Calltimeuntil.
I should tell you that this'll require some more in-depth use of variables. Division is done, by dividing the
Variable by the Operand, but only keeping the whole number, so 10 divided by 3 is 3, not 3 r1. The Mod
is the exact opposite. It divides, but instead, keeps the remainder, and drops the whole number. Catch
my drift? :)
Start by Change Variable [xxxx]Minutesuntil Set Timer Seconds Remaining (In Other drop down menu)
Do the same for [xxxx]Secondsuntil. Now, Change Variable [xxxx]Minutesuntil Divide by 60.
Do the same for [xxxx]Secondsuntil, but instead, use Mod and keep it at 60.

Now, you'll want to remember what variable number Minutesuntil and Secondsuntil is. That;s where the [xxxx] is.
Create a Fork Condition and have If Switch [xxxx]Day ON, Else Case. Now, between the Fork Condition and
Else case, create another Fork, this time If Variable [xxxx]Secondsuntil is 9less Else Case.
Between the new Fork condition and Else case, insert message and put this message in.

\v[xx]:0\v[xx] until Nightfall. The first [xx] is the number if Minutesuntil, the second is Secondsuntil.
Now, between the Elsecase and End Case of that Fork, create another message. Put in it:
\v[xx]:\v[xx] until Nightfall, same principles, but take out the '0'. Now, copy the entire 2nd Fork
and Paste it between the Else Case and End Case of the First fork. Then, edit the message,
replacing the word 'Nightfall' with 'Daybreak'. Do it with both messages, and at the very bottom of
the event page, Change Switch [xxxx]Calltimeuntil OFF. That's your clock. Make sure your character
gets it some time. It'll be handy to use to check if this script works.


Switches and Variables needed;


If you'll go to sleep in a bed, maybe in your room, which is indoors, you'll want to wake up in the morning. Also
because ur indoors and you want the screen tone right, there'll be an Event which sets the screen tone to normal.
If that happens, and you want your screen to go black. So, Change Switch [xxxx]Sleep on and carry on. At the end
where you wake up, Set the Timer to whatever a part of the day lasts, and start the timer. Then Change switch
Day ON and Night OFF. Then turn Sleep OFF. Now, on the map with ur bed or where u sleep, find the paralell
process event which sets the screen tone to normal, and add a new page. Set the condition to Switch [xxxx]Sleep ON
and Push key. Leave the command box empty. And that's it!

This is the end of the tutorial, which is rather long, I think. If you have any questions, please e-mail them to Enjoy!