Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[VX] Kylock's Time System 1.5

Kylock's Time System VX 1.5
by Kylock

This script will track game time as well as automatically tint the screen for a day/night effect.
You can make events dependent on time thanks to game variable output support.
You can customize how dark you want it to be at what time.
You can designate certain maps as "outside" so they are the only ones that are dark at night!  (Add [KTS] to map name.)
You can choose the speed of your game's clock.
Because the entire time system is an object, its possible to instance or have more than one game clock.  PM me for details if you really need this functionality.

Detailed installation and script usage instructions are included in the script header, just like all my other scripts.  The usage is VERY similar to the XP version that I wrote over a year ago - if you are familiar with it at all.

To answer a few question before they are asked:
- I am not including weeks, months and years because it gets too complicated when you have a different amount of days in each month for example.  The primary intention of this script is to allow you to build your events based on hours in the day and time periods throughout the day.  (Ex: The time-locked vault can only be opened between 2 and 3.  or The guy with the password can only be found drinking in the bar at midnight.)
- The [KTS] that you put in your map names remains hidden to other scripts, like Map Name Popups and such.
- For script compatibility reasons, if you use a CMS, you might get better results if this script is located ABOVE your CMS.  If you have a CMS and want a time window added to it, this is a really easy hack for any scripter, so please make a request in the appropriate Script Requests Forum.
- There are no screenshots because that would be pointless.  You can define your own screen tones and there is an added window for time right above the gold window in the default menu.  That's all there is, I promise!

Now, the script itself:

Code:
#==============================================================================
# â–  Kylock's Time System VX 1.5
#     6.3.2008
#------------------------------------------------------------------------------
#  Script by: Kylock
#==============================================================================
#    Mostly rewritten since XP version.  Cleaner code and less intrusive (more
#  compatible).  This is my comprehensive time and day/night system.  This
#  script adds a new window to the game menu, so if you use a CMS, then place
#  this script ABOVE it so that it won't mess up your CMS.  If you use a custom
#  script that makes changes to the battle background, place KTS below it so
#  that you don't get the delayed-tone effect in you battles.  Other than that,
#  there shouldn't be any other script compatibility issues.
#    I've tried to make this script as customizable as possible, the settings
#  are found immediately following this header.  Although time output to game
#  variables is optional, I strongly suggest using it so that its easier to
#  build your events based on the time in the game.
#==============================================================================
# â—
 
Great system, I was ironically looking for something like this last night. One thing though. I have an edited battleback, and when it goes to the battle screen, there is a small delay in the changing of the tint to make it right. Any fix for this?

Here's my edited battleback thing:

Code:
  def create_battleback
    source = Cache.picture($game_variables[100])
    bitmap = Bitmap.new(640, 480)
    bitmap.stretch_blt(bitmap.rect, source, source.rect)
    @battleback_sprite = Sprite.new(@viewport1)
    @battleback_sprite.bitmap = bitmap
    @battleback_sprite.ox = 320
    @battleback_sprite.oy = 240
    @battleback_sprite.x = 272
    @battleback_sprite.y = 176
  end


Also, I think an interesting addon would be to obtain the current time on the player's PC at the time a new game is started, and make the game start at that time. This way, you could do a pokemon-like thing where the time is the actual time of day.
 
kaze950":rggtfm2l said:
Great system, I was ironically looking for something like this last night. One thing though. I have an edited battleback, and when it goes to the battle screen, there is a small delay in the changing of the tint to make it right. Any fix for this?

I noticed this myself, I'll have that smoothed out soon.


Update: FIXED.

Since the method doesn't seem to be aliased in that script, put the time system under it.  Should work fine.
 
Okay, when I put in the updated script the '$kts.stop' function no longer seems to work. It was working before, with the old script. Maybe something was changed accidentally.

Also, I'm trying to do an inn event where you can choose for a wake-up call, so to speak. But, I change the time and have a text event (Something like, "A short sleep, huh? Well, suit yourself" if the player selects a time 1 period ahead of the current one), and the game freezes sort of (the music still plays).
 
kaze950":qiqdewrf said:
Okay, when I put in the updated script the '$kts.stop' function no longer seems to work. It was working before, with the old script. Maybe something was changed accidentally.

Also, I'm trying to do an inn event where you can choose for a wake-up call, so to speak. But, I change the time and have a text event (Something like, "A short sleep, huh? Well, suit yourself" if the player selects a time 1 period ahead of the current one), and the game freezes sort of (the music still plays).

Okay, made some changes to the original script to test the stop and go.  The new method works sort of like, when you say stop, it captures the time, but the clock keeps running.  When you say go, it resets the clock to where it was when you said stop.  See how that works.  The previous method counted frames, but I think that the frames per second aren't going to be consistent all the time.

When you use the jump function, a few seconds of lag is normal.  Just make sure you are using $kts.jump_to_hour(18) and NOT $kts.jump_to_hour(1800).  Since the hours cycle back to 0 after 23:59, the script can get stuck in an infinite loop if you're not careful.
 
$kts.jump works fine, but I still can't get $kts.stop to work. I think I'm doing it right.

I have an autorun event with the script '$kts.stop' and than the event erases itself. I've tried doing events with action button, but that  failed to work either.
 
$kts.stop doesn't technically stop the clock.  It remembers where the clock is.  For example, you use $kts.stop when the clock is at 0:04.  It will keep going, but when you use $kts.go - it will then rewind the clock back to 0:04.  Its a workaround, but it works.
 
So is there anyway to actually "freeze time", so to speak? I'm looking to make it so time only passes on the world map, but not anywhere else.
 
I'm looking at adding game switch code to make it easier to create events based on the current time period. As well as cleaning up that pause feature.  In the next version, look forward to being able to stop the game clock with a switch.  This might make what you're trying to accomplish easier.

I'm thinking of scaling back to 4 time periods, day/sunset/night/dawn to make things easier for events.  Then making a game switch linked to each time period.  I need feedback on this from the community =p
 
Updated to 1.3
* $kts.stop now REALLY stops everything (as far as time is concerned)
* Implemented game switch output. Now if you want an event to exist only at night, Just require that Switch 1 is ON. (see script header for more details)
 
I'm using this script for my game, which is great by the way. but I was wondering what and where the days you can set up come into play, I don't see them shown anywhere or even used, so I'm just wondering what they are for?
 
They only exist for variable output.  They were in the original XP script because someone wanted to make an event only exist on Thursday or something silly like that.  I tried to convince him that nobody is going to stand around waiting till Thursday for any event, but he insisted on the feature =p

Really though, you are right.  There is absolutely no practical use for it at all.
 
Kylock":1na2khmr said:
They only exist for variable output.  They were in the original XP script because someone wanted to make an event only exist on Thursday or something silly like that.  I tried to convince him that nobody is going to stand around waiting till Thursday for any event, but he insisted on the feature =p

Really though, you are right.  There is absolutely no practical use for it at all.

Ah, okay. Thanks for that info.
 
Well, it has some use though. If the day name is stored in a variable, one could make a window to show the day in the menu, such as games like Oblivion where there is a day and such. Might be helpful in a game where religion is prominent and they have a certain day when they go to church or temple or something.
 
kaze950":3uh3wowa said:
Well, it has some use though. If the day name is stored in a variable, one could make a window to show the day in the menu, such as games like Oblivion where there is a day and such. Might be helpful in a game where religion is prominent and they have a certain day when they go to church or temple or something.

lol There ya go.  I guess given the right circumstances, it can be useful =p

I guess my answer was more along technical lines relating to the rest of the script's functionality.
 
I'm having some trouble when using this script. When I go to the debug screen, and choose V [0001 - 0010] a error message comes up :"Script 'Scene_Debug' line 109: ArgumentError occured. Comperison of String with 99999999 failed."


... And this is on line 109.
Code:
       if $game_variables[current_id] > 99999999

How can this be fixed ?

[edit]
Oh yeah, I would also like to see an in the game an small box showing the time. Not only in the menu.
 
islandstudios":gwluqm3t said:
I'm having some trouble when using this script. When I go to the debug screen, and choose V [0001 - 0010] a error message comes up :"Script 'Scene_Debug' line 109: ArgumentError occured. Comperison of String with 99999999 failed."


... And this is on line 109.
Code:
       if $game_variables[current_id] > 99999999

How can this be fixed ?

[edit]
Oh yeah, I would also like to see an in the game an small box showing the time. Not only in the menu.

If you are using the default settings, this error doesn't happen, at least in a sterile project.  Either you are outputting to a variable that out of range, or another script could be using the same varialbe that kts is to give a weird error like that.

As far as a HUD goes, that's a special script request, I don't plan to actually add that to the script.
 
Shut48":pisy88xy said:
how long do you have to wait until its night?

The time is in the menu, it'll be dark during night hours.  It will never be dark, however, unless you put [KTS] in your map name.
 
I'm having some trouble getting this to work with a certain event. Basically, if you choose to have dinner with the family, the time jumps to 7. However, instead of the events disappearing from their Daytime places and going to their Sunset places, they stay put until I exit the area and come back. I tried making the event manually shut off Daytime switch and turn on Sunset switch, but then when I exit and come back they've reset to their Daytime positions, when they should still be at the table eating dinner.

I probably haven't explained thoroughly enough, but I think I'm doing it right and it's frustrating trying to make it work how I want it to :/
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top