Basic Game Time + Night/Day

1st: Awsome job!


2nd: i have read this entire topic and all but one of my questions have been answered, so here we go.


I figured out how to make time stop in my stores, and my characters to sleep for 8 hours, and how to make it so a door only opens during a certain time frame, from reading the above entries.


what i would like to know, is how i can make a monster and/or troop only appear at certain times in the day, like example a vampire only appearing at night.


i treid figuring it out myself with a conditional branch in the event page of a troop, but i just confused my self lol.


any and all help is appreciated!


thank you so much
There isn't a way offhand to make only certain troops appear at certain times while using the maps random encounters. Though that would be neat...

Hello! Im very new to this script stuff but i really would like to use this scrip!


I have an issue where okay, I copy your script, I post your script under Main.( thats the right spot yes? >.<) and... place it in ofc. Then make an event


and go to the script call and i put like... GameTime::set(720), Id like to see it night.


Then i get this error:


Script 'Game_Interpreter' line240: NameError occured.


uninitialized content Game_Interpreter::GameTime


I get this dang error on so many scipts.... No idea what i means


Im using The RPG Maker VX Ace... I heard not many scipts work on it, Is that the case for this script?
They go above main, yes. Not below it. Otherwise they wouldn't work.
thanks for the quick reply.

i have one ore small question, is there a way to set certain maps, to display ??:??,for example. for a twighlight zone like map, where the time/space demsion and what not is suspened or alltered. "I don't think we're in Kansas anymore."

Edit: silly me, i can make a bunch of NPC/Monsters that only appear at night, and have them chase me until they touch me which will start a battle. not a problem, i think i like it more than random encounters cause being able to see them you would know the moon aint right...
I'm trying to add a tint screen but the cycle seems to be affecting all tints.  Any way to put in custom tints to maps not involved with the cycle?  I've added these maps to the exclusion list so they don't become affected by day/night, but they need a perma tint to em.
thanks for the quick reply.


i have one ore small question, is there a way to set certain maps, to display ??:??,for example. for a twighlight zone like map, where the time/space demsion and what not is suspened or alltered. "I don't think we're in Kansas anymore."


Edit: silly me, i can make a bunch of NPC/Monsters that only appear at night, and have them chase me until they touch me which will start a battle. not a problem, i think i like it more than random encounters cause being able to see them you would know the moon aint right...
Not as it stands, but an interesting feature I'll probably look into.

I'm trying to add a tint screen but the cycle seems to be affecting all tints.  Any way to put in custom tints to maps not involved with the cycle?  I've added these maps to the exclusion list so they don't become affected by day/night, but they need a perma tint to em.
You'll have to pause the tint for maps that you want to custom tint, just the script call GameTime.pause_tint(true) before the tinting and then just GameTime.pause_tint(false) when you're done.
Not as it stands, but an interesting feature I'll probably look into.

You'll have to pause the tint for maps that you want to custom tint, just the script call GameTime.pause_tint(true) before the tinting and then just GameTime.pause_tint(false) when you're done.

Doesn't seem to want to work.  Script call is just putting the script into the event right?
Yah, just putting


GameTime.pause_tint(true)


into the script call box in the event.
I tried putting it at the beginning of the whole intro until the cave scene but it doesn't work.  I also tried true/tint/false as well and that doesn't work.  Maybe I'm missing something?
Must be, this is how it should be set up:

Spoiler
EventSetup.png
Which works fine for me.
I did that exact same thing in a separate parallel process to ensure it wasn't conflicting and it still shows night time.

Edit:  I put the script on true manually and now the first map works correctly but when the next map comes up it resets back to regular time instead of disabled.
What do you mean resets back to regular time?
Back to default 0,0,0,0 vanilla tint.
This seems to be one dilly of a pickle, I don't know what's wrong. Maybe if you could **PM** me the event setup you are using, or even the project if possible, I could take a real look.
Can you add a feature where you can buy something like a flashlight and you can use it at night time by pressing a certain button? And have it run on batteries that will expire if overused?
Sounds like something you'd want to event, and also a job for a light effects script~
Can you do that the game changes the tint every "TIME_COUNT" instead of certain hours, and write in a commentary near "PRESUNRISE_TIME, SUNRISE_TIME, NOONSTART_TIME, NOONEND_TIME, PRESUNSET_TIME, SUNSET_TIME" and "MIDNIGHT_TIME" the hours of when the tints changes?
Hey, someone probably asked this already, but I want to make it so that right as this certain event or script occurs, the time changes. How exactly can one do that? Please and thank you.
Can you do that the game changes the tint every "TIME_COUNT" instead of certain hours, and write in a commentary near "PRESUNRISE_TIME, SUNRISE_TIME, NOONSTART_TIME, NOONEND_TIME, PRESUNSET_TIME, SUNSET_TIME" and "MIDNIGHT_TIME" the hours of when the tints changes?
Those variables already set the hours of when the tint changes, it's just in minutes of the day.

Hey, someone probably asked this already, but I want to make it so that right as this certain event or script occurs, the time changes. How exactly can one do that? Please and thank you.
GameTime.set(###) and GameTime.change(###) For example:


GameTime.change(60)


increases the time by an hour, whereas


GameTime.set(60)


would set it to 60 minutes into the day, 1am
Thanks I'll try that, but earlier I tried this: 

"Variables!? You can do that! If you wanted to set a variable to the current time you can use the script call:

$game_variables[]=(variable id, GameTime::hour?) to set variable id to the hour
$game_variables[]=(variable id, GameTime::minute?) to set variable id to the minute
$game_variables[]=(variable id, $game_time) to set variable id to the minute of the day (range of 0-1440)

To change time with a variable? Just as complimicated! Script calls:
GameTime::set($game_variables[](variable id)) to set time to the number of the variable, in minutes
GameTime::change($game_variables[](variable id)) to increment time in minutes by the variable (available in the most recent version only)"

It kept saying: error, unexpected ','

My guess is that if I wanted it to be 2pm, I'd just make an event script that goes: $game_variables[]=(14, GameTime::hour?)

right? 
I uh... have no idea what I was talking about back then, I suppose... can't believe I ever did it that way.


The $game_variables thing works like:


$game_variables[id] = value


and


GameTime.set($game_variables[id])


$game_variables[14] = GameTime.hour?


Wouldn't change the time to be 2pm but would set variable #14 to the current hour.


In that situation, you aren't changing time by changing the variable, but changing the time based on the value of the variable.
@Vlue, I mean... For example, do you know Legend of Zelda Ocarina of Time? In Hyrule Field the tone is changing every second because the sun is moving, so, what I was telling is if you can do that the tone changes slowly instead of instantly, for get a more realistic feel rather than "It's 8PM, the sun is hiding *light suddenly disappears*".

Maybe you can do something like an autoincrement/decreasement of R/G/B colors, calculed automatically by the current and next tint screen, being divided to X parts and the result would increase/decrease the value, then you add .to_i for avoid crashes due the use of decimals on "tone_change" (haven't tested it).

For example:

  •     Night tint is -68,-68,-68,0.
  •     Starting from 4AM, the tint changes slowly to 34,-34,-68,0 (sunrise) until reaches 6AM, then changes slowly to 0,0,0,0 (noon) until reaches 12PM
  •     Starting from 3PM, the tint changes slowly to 68,-34,-34,0 (sunset) until reaches 6PM, then changes slowly to -68,-68,-68,0 (night) until reaches 21PM and keeps in that tone until 4AM.
Now, get the number that you must add/remove on each RGB value for reach the next tint, example:

  •     21PM Tint to 4AM tint: R -68, G -68, B -68 to R 34, G -34, B -68 is +102, +34, +0.
  •     From 21PM to 4AM there is (default time in your script) 360 seconds, so... 102/360 = 0,283... 34/360 = 0,094.... 0/360 = 0 😮
  •     Now the result each calculation is stored and that value being added/removed every second to valR, valG, valB, and when the game reaches 4AM, the values stored there are cleared for calculate the next tint.
  •     Change the custom tints to arrays, Tone.new won't be used in the configuration anymore.
  •     And now, add valR, valG, valB to the respective start_tone_change, for example, $game_map.screen.start_tone_change(Tone.new(SUNRISE[0]+valR,SUNRISE[1]+valG,SUNRISE[2]+valB,SUNRISE[3]+valY), tint)
I've tried to do it by myself but... my scripting skill is realllllly poor, but I believe that you would know what to do.

Original thread: https://forums.rpgmakerweb.com/threads/basic-game-time-night-day.1079/