Jump to content
Patrick V

Day and Night Time Tutorial with Demo

Recommended Posts

This is more of a demo than a written tutorial, but I will run you quickly through the logic of it and you can cut and paste it straight to your own game if you have a need for it.

 

--> My Mediafire isn't working for some reason, this link makes you wait 45 seconds >.<

It's only 1.5 mb though!

 

Time System Demo

http://uploading.com...e%2BSystem.exe/

 

First we need variables

 

- Seconds

- Minutes

- Hours

- Days

- AM/PM

 

o This entire system will play out in the common events. Just like a clock we will tell it to add 1 second endlessly.

o When 60 seconds have accumulated we will at 1 minute, then reset our variable "seconds" to 0 so it can start over again.

o Now that our Minutes are accumulating, we add a condition that if we get 60 minutes, we add 1 hour, then like before we reset our

minutes to 0 so it can count back up again.

o This is where it gets tricky, when we gain 12 hours we want it to change from AM to PM, so our AM/PM variable will go from 0,

representing AM, to 1, now representing PM. So our condtional branch will read - if AM/PM = 0 and hours = 12 then AM/PM ==1, else AM/PM == 0 -- So this says that if it's AM now, and the counter hits 12, then it will change to PM, otherwise if the hours hit 12 and it's PM, change to AM

o Now we have a clock counting to 12 and changing to PM, so we now make another condition that says if the Hours reach 13 (will apear to be 12:59) then we reset hours to 1. This is where the last condition comes in, it will have already changed AM to PM at 12,

so now it will be 1PM

o So we're going to count up again now to 12, with the AM/PM variable reading 1 (PM)

o When the clock reaches midnight (12:00AM) we want to add 1 to the Day variable, so back in our condition for AM to PM, we will place add 1 to the day variable. So if hours = 12 and AM/PM = 1 (it is midnight) change the day counter.

 

That is a basic clock, and I know it sounds like a jumble of crap but when you look at it in the demo, it is well commented and you will understand a bit better.

 

To display the time, we will create another common event, a parallel process. In it will be a condtional branch checking if a designated key is pressed (I use Q -- the game recognizes this as the L button). If the key is pressed, display the string of variables for the clock

example - "The time is \v[1]:\v[2] Day - \v[3]"

But there is a problem here. AM or PM, so when the key is pressed we place another condition in if AM/PM = 0 (it is am) then

"The time is \v[1]:\v[2] AM Day - \v[3]" else "The time is \v[1]:\v[2] PM Day - \v[3]" One output is AM and one is PM

 

So now the condtions will display the string with the correct AM PM placement. But another problem will appear. What if there have only been 5 minutes to the hour. It will display the variables like this "8:5 AM Day 1" So we use another conditional branch that states

if the minutes are less than 10 (9,8,7,6,5,4,3,2,1,0) then we will write the string "The time is \v[1]:0\v[2] PM Day - \v[3]"

Look closely at that last string, we have added a 0 after the colon ( :) to create the illusion that it is a clock readout. Now the clock will say 8:05 AM Day 1

 

And there we have a working time system. This is the (seemingly complicated) foundation for your day and night system.

 

dayandnight.png

 

Your day and night system is a condtion by itself inside of common event for your time system. This is fairly simple --

If hours = 8 and minutes = 30 then dim screen to dark and turn on NIGHT switch

If hours = 5 and minutes = 30 then brighten screeen to day and turn off NIGHT switch

 

Included in the demo, and completely removeable, is a sunset time, at 7:00PM it will dim screen to mimic the sunset.

 

And there we have a functional, non scripted Day and Night, Time system

 

Now we have fun with it.

 

In the turtorial I have included events effected by the time:

 

o The shop will close at night, and if you're inside, it will kick you out.

This is done by copying the first page in the transfer event and pasting it as the second page. Set the conditions to (Night switch ON) and change the event trigger to Autorun.

Now you will get kicked out at night time. On the outside, you copy and paste the first page of the door, like before set the conditions to (Night switch ON) So now you will be kicked out and not alowed back in. You can have fun with this by adding a lockpicking skill that will allow you to break in and steal stuff, so many possibilities.

 

o The inn accounts time of day, and handles it properly. If you go to the inn at night and sleep, you will wake up the next morning at 7 am. But it was tricky because if you go to bed at 2 AM, the inn has to recognize that and not add 1 day to the counter. So I've included a common event you can slide into any inn, using this time system.

 

o Lamps and torches that light up at night.

 

 

Hopefully you all can find use to this, I've made it so that the switches used and the variables used are all 95-100, so hopefully it will just be a plug and play for you. You could even use this demo as a foundation for your own game, in this case, please credit me appropriately. If you've managed to create events yourself with this chicken-scratch tutorial, then no credit needed.

 

Any feedback is appreciated!

 

PatV

Edited by Patrick V

Share this post


Link to post
Share on other sites

Perfect was looking for an easy way to implement this, it seems I forgot how to, last time I made a time function was RM2K3.

1 question is there anyway I can get the time to display on the hud, much like majora's mask I want something to tell the player what time it is always.

 

Also is it possible to not change screen color when you enter buildings or dungeons? Is there a way to disable screen colors such as evening or night but have them apply once you leave a building or dungeon?

 

Last question how can I make it so that the time still passes even when in combat?

Edited by Ice Nick

Share this post


Link to post
Share on other sites

I must say, I like this very much. I will be using this. Thank you.

 

-side note: I would suggest media fire for uploading and sharing. I find it way better than having to wait so many seconds to download something.

 

again thank you for this tutorial.

Share this post


Link to post
Share on other sites

1 question is there anyway I can get the time to display on the hud, much like majora's mask I want something to tell the player what time it is always.

 

This seems like it wouldn't be too hard to achieve. I'm pretty sure for any hud you'd need a script, but you could have them incorperate a clock into the graphic, and use the variables to control the numbers (var 95,96,97,98, 100)

Celianna at rpgmakerweb.com has a method for time and a hud, maybe her system would be better suited for your needs.

http://www.rpgmakerv...showtopic=43374

 

Also is it possible to not change screen color when you enter buildings or dungeons? Is there a way to disable screen colors such as evening or night but have them apply once you leave a building or dungeon?

 

There would be a way to do this, but it might be a pain in the rump. When I sit down for a bit later I could add it to the demo.

It would involve altering the events and putting a condition on the tinting, perhaps a switch. On each transfer for the building you want to do you would add a common event (just one common event would cover every building) it would say

If night time, change tint to day (this common event would be with the transfer from the outside to inside)

 

and on the inside, upon leaving the building it would check again

if night time, change tint to night

Both of these conditions would also turn on a switch that wouldn't allow the tint to occur.

 

Last question how can I make it so that the time still passes even when in combat?

 

I'm pretty sure there's away if you play with the scripts, as far as I know though you can't naturally have common events run during battles. But again, I'm still pretty new so I could be mistaken.

 

I must say, I like this very much. I will be using this. Thank you.

 

-side note: I would suggest media fire for uploading and sharing. I find it way better than having to wait so many seconds to download something.

 

again thank you for this tutorial.

 

Thanks syrus, and I swear I ALWAYS use mediafire except this one time. When I would try to upload to my mediafire, the progress bar wouldn't move! Lol when I update the Demo I'll be sure to try again :D

Share this post


Link to post
Share on other sites

 

Also is it possible to not change screen color when you enter buildings or dungeons? Is there a way to disable screen colors such as evening or night but have them apply once you leave a building or dungeon?

 

Last question how can I make it so that the time still passes even when in combat?

I think it would be cool that if it is night time..to make fireplaces....and wall lamps light up..I mean...if it is night time...it surely should not look like the sun is shining through the windows giving false lighting at night would look better.

Share this post


Link to post
Share on other sites

This seems like it wouldn't be too hard to achieve. I'm pretty sure for any hud you'd need a script, but you could have them incorperate a clock into the graphic, and use the variables to control the numbers (var 95,96,97,98, 100)

Celianna at rpgmakerweb.com has a method for time and a hud, maybe her system would be better suited for your needs.

http://www.rpgmakerv...showtopic=43374

I actually saw that script but its for VX, yeah I would want something like that telling the player what time it is or rather have it toggled on by Q rather then getting a text displaying the time. When I have time I was gonna look into it but none the less I thought I would ask as you might save me hours and hours of failure lol.

 

 

There would be a way to do this, but it might be a pain in the rump. When I sit down for a bit later I could add it to the demo.

It would involve altering the events and putting a condition on the tinting, perhaps a switch. On each transfer for the building you want to do you would add a common event (just one common event would cover every building) it would say

If night time, change tint to day (this common event would be with the transfer from the outside to inside)

 

and on the inside, upon leaving the building it would check again

if night time, change tint to night

Both of these conditions would also turn on a switch that wouldn't allow the tint to occur.

Yeah this is kind of a big one for me, because I want more then Night and Day, I want to have dusk, dawn, etc.. I was wondering if there was an easy way or at the least a script to make life easier then adding all these conditions to every event. Not a total deal breaker.

 

I'm pretty sure there's away if you play with the scripts, as far as I know though you can't naturally have common events run during battles. But again, I'm still pretty new so I could be mistaken.

Personally this is a must, time shouldnt stop when fighting monsters. If you know how to do this great! Or at the least pointing me in the right direction lol.

 

Anyway great demo/tutorial, thanks for taking the time to make it and answer questions... I forgot how much it took to make a time system :)

 

I think it would be cool that if it is night time..to make fireplaces....and wall lamps light up..I mean...if it is night time...it surely should not look like the sun is shining through the windows giving false lighting at night would look better.

Yeah not a deal breaker, but when I walk into my house at 10pm, I have lights to light up the whole house, I dont just see black with a few candles to light up parts of the room. It would only be specific to some buildings and dungeons. Maybe if it is possible (I have no idea how to do this) have lamps and candles emit an area of light while keeping the "night" tint overall. That would be the coolest most atheistically pleasing solution.

Share this post


Link to post
Share on other sites

I know what you mean about the lighting and stuff, it is troubling to do it all with events. This would be a good question to ask in script request, for a lighting system, maybe attach the demo to it so they know what they`re working with.

 

As far as I can tell from an hour and a half of screwing with it, making the transfers seemlessly change from inside to outside is just a pain in the butt. I guess I`ll just leave the demo as it is. Hopefully you can get a script to help you with you Ice Nick, but I lack that skill :P

 

Good luck!

Share this post


Link to post
Share on other sites

I know what you mean about the lighting and stuff, it is troubling to do it all with events. This would be a good question to ask in script request, for a lighting system, maybe attach the demo to it so they know what they`re working with.

 

As far as I can tell from an hour and a half of screwing with it, making the transfers seemlessly change from inside to outside is just a pain in the butt. I guess I`ll just leave the demo as it is. Hopefully you can get a script to help you with you Ice Nick, but I lack that skill :P

 

Good luck!

 

What do you mean? Entering buildings to change the tint? Then leaving to apply tint if Night? It would be cool I guess but not the end of the world.

 

I tried to include a hud in your demo... I have no idea and failed miserably... Any suggestions on who to ask or if theres something out there that achieves this?

 

Ill check back here if theres a way to have time flow in combat, if I do figure it out would you be interested in adding it into the demo? Key word IF

Share this post


Link to post
Share on other sites

Anything youcan add to the demo would be appreciated. Especially to the means of customization, everyone loves to be able to add their own flair, like different style HUDs. As far as scripters go, I know no one lol. Maybe I'll look into it this week, I'm off work for 3 weeks maybe I could figure it out haha.

Share this post


Link to post
Share on other sites

Hey there, as a request for someone, i made this little script hud that works with your system to show what time of day it is.

The seconds go by really fast on the hud, was this intentional?

 

I'll post it here, if you don't like it, ill remove it (Just please send a PM if you want it removed)

 

 

#Wherever you see $game_switches[1]
#Change 1 to the switch to turn the hud on/off

class Window_MapTime < Window_Base
 def initialize
   super(0,0,200,80)
   @ampm = "AM"
   if $game_switches[1] == false
     self.opacity = 0
     time_draw
   end
 end

 def time_draw
   if $game_variables[100] == 1
     @ampm = "PM"
   else
     @ampm = "AM"
   end
   @hours = $game_variables[97] # Hours
   @mins = $game_variables[96] # Mins
   @secs = $game_variables[95] #Seconds
   text = @hours.to_s + ":" + @mins.to_s + ":" + @secs.to_s + " " + @ampm
   draw_text(0,0,200,40,text)
 end

 def update
   if $game_switches[1] == false
     contents.clear
     time_draw
   end
   if $game_switches[1] == true
     self.opacity = 255
   end
 end
end

class Scene_Map < Scene_Base
 alias time_draw_on_map_time create_all_windows
 def create_all_windows
   time_draw_on_map_time
   @maptime_window = Window_MapTime.new
 end
end

 

Edited by Anton

Share this post


Link to post
Share on other sites

Thanks for that Anton, I love it! I tried editing it so that right beneath it would say

 

Day: "#"

 

Lol other than that one thing little missing, I really like it. The reason that the seconds go by so quick is because I don't use a wait command, and the minutes were originally intended to pass by like seconds so that the days weren't too long, making the "seconds" like miliseconds lol.

 

And Ice, I looked at that script and it does look really cool but it's pretty well hebrew to me. Maybe if you played with it for a while you could figure it out but I don't have that kind of patience! lol! It looks cool though, when it was night and you went in the cave it would go back to being light inside the cave.

 

Anton, if you know how to throw pictures in beneath that where the time is, that would look cool.

Perhaps something like these:

 

hudbg2.th.png

 

hudbg1.th.png

 

I appreciate the intrest guys, we could turn this into something really sought after if we try :D

Share this post


Link to post
Share on other sites

Lotano, glad I could help, feel free to use the demo as a base to start a game on, save you the trouble of copying and pasting it to a blank game. Lol and sorry Anton, I've been on like one message board before and it was to find out if I had herpes.

 

EDIT: They were ingrown hairs. lol fyi.

Edited by Patrick V

Share this post


Link to post
Share on other sites

This is a greate event and it works well. I would like to offer some edits that many of you may enjoy and use.

First Edit: To change the speed that the seconds increase simply change the rate that seconds are converted to minutes and minutes to hours. DO NOT USE WAITs because they can cause your character to lag across the screen as a wait freezes everything and being that it is a parallel event it will constantly be executing the wait command

 

Second Edit: Many of you asked if it was possible to prevent tint from happening while in a building. The answer is yes. Simply add a conditional branch above where the tint occurs. Make sure the box that says "Handle When Conditions Do Not Apply is Unchecked" now create a new switch and name it something like Allow Window Tint. If that switch is on the event can tint the screen. If that switch is off it will skip right past the tint and since you unchecked the box it will continue with the event.

***NOTE: If you make this addition/change you will need to edit the event a bit where it checks if minutes, hours, and seconds are equal to 0. You should change the check on minutes and seconds to be greater than or equal to 0 because if your event is running while in buildings but you have the tint switch off once you exit the building and turn the tint switch on the tint will not occur because the event looks specifically if it is equal to 0 and you may exit a building while the minutes are at 13 or the seconds at 01.

 

Third Edit: My above suggestion is for those that want to make sure the time script is still running in the background even though it is not tinting the screen. this suggestion is simply to switch the whole system off when you enter a building to freeze everything.

 

I have made these above edits and I have not run into any problems yet although i haven't had much extensive testing. The event system is great. These are just meant to help enhance the capability of it.

Share this post


Link to post
Share on other sites

A slight edit I made that others may wish to do if you don't like days incrementing infinitely. I wanted days of the week in my game, so i could do things like having certain stores have sales on wednesday or have certain villager NPCs seeming to work unless it's the weekend.

 

The way I did it is I set it so when the day increments, if it causes the day variable to hit 8, the variable is reset to 1. Then I added a few more conditional branches to the time display to display Monday if the variable is 1, Tuesday if the variable is 2, etc. Just wanted to throw that edit out there for anyone who might want to use it.

Share this post


Link to post
Share on other sites

I clearly have an intelligence problem because I can't figure this thing out. I find your directions hard to follow and I am running into road blocks.

 

Even if I copy all your code and variables over to my own project I still cannot get this to run. Granted I am new to RPG Maker but is there something to parallel processing that I am missing?

 

I would really appreciate some help :s

Share this post


Link to post
Share on other sites

WARNING
The web site that is hosting the file "time system.exe" upload.com or something like that is VERY VERY BAD. It use to take 45 seconds then you could download file free. now they appear to be making their money off programs like conduit. Conduit and some of the other programs they try to get you to accept are very hard to get off your PC once they get on there. So if you do use the download link be sure to click decline button (hard to see bottom left) will need hit it about 5 times for (each spyware app they try get on you)  and when it asks are you sure you want to decline? you need to choose cancel and not accept (yes cancel) they try to trick you at every turn. Conduit is famous for this type of BS. 

I am going to host this file on my google drive If the user who created the file has any objections please let me know.
https://drive.google.com/file/d/0B_3Ge_b1unWseWE3SmVVQVIyMkk/edit?usp=sharing
 

Share this post


Link to post
Share on other sites

Hello! I've tried to download your demo but Google says the file is malicious.   I've hashed up a time system, however, when I move to the next map the timer starts back to the beginning, EVEN if I use separate variables for each hour (it's super simple and is just 8am to 12am with the hour changing every real life minute) LONG STORY SHORT - How did you get the common event to keep going and remember what time it left off  when the player moves to a new map?

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×