Group: Revolutionary
Posts: 168
Type: Artist
RM Skill: Advanced
This is a MOD version of KTS (Kylock's Time System) that will use Date and Time settings from your PC.. So now the time in game will be REAL time.. KTS V.1.5 MOD V.1.1 (30-05-09) MOD by reijubv Mod is an abbreviation of modification
#============================================================================== # ¦ Kylock's Time System VX 1.5 MOD V.1.1 # 6.3.2008 30.5.2009 #------------------------------------------------------------------------------ # Script by: Kylock # MOD by reijubv #============================================================================== # MOD changelog : # > V.1.0 (24/5/2009) = Initial release # > V.1.1 (30/5/2009) = Now with season and auto weather feature #============================================================================== # Remember Pokemon games real time system? # This mod (modification) version of KTS will do the same! # This fan made mod for Kylock's Time System VX 1.5 will adjust the # game time automatically to be same as real world's time. #------------------------------------------------------------------------------ # Actually, this mod will takes the time format from your PC and uses it in the # Script, in 24 hours format. # With this mod, you can make events only occurs once a week or whatever.... #------------------------------------------------------------------------------ # NOTES: # 1. Don't use the normal KTS with this one! # 2. $kts.go,$kts.stop, kts.sec(n),$kts.hours(n),$kts.days(n),$kts.jump_to_hour(n) # are all deleted in this mod. # 3. START_DAY, START_HOUR, AMPM, DAYNAMES and SPEED variables are also deleted. # 4. 8 new variables to use : # a. WEEKDAY = 0 to 6 (Day index in one week) # b. MONTH = 1 to 12 # c. MONTHNAM= Jan, Feb, May, etc.. # d. MONTHDAY= 1 to 31 # e. YEAR = 1994, 2009, etc # f. SEASON = Season Name (Summer, Spring, ETC) # g. WEATHERN= Weather's name # h. WEATHER = Weather Id, 0 is clear weather # 5. 4 new switches to use : # a. SPRING = This switch is on during spring season # b. SUMMER = This switch is on during summer season # c. FALL = This switch is on during fall season # d. WINTER = This switch is on during winter season #=============================================================================== # Credit mainly goes to Kylock # and then. reijubv # (Cuz I think I deserve something better than just a "thanks"..) # Have a nice day! #=============================================================================== # ? Auto-tone Instructions #------------------------------------------------------------------------------ # Maps designated as outdoors are the only maps to be affected by this # scripts use of auto-toning. To signify a map to be "outdoors", you must # include [KTS] In the name of the map. For example, you world map could be # named "World Map [KTS]" or "[KTS] World Map". Provisions are made later in # the script to remove [KTS] from the map name when it's read by another # script. This means that "[KTS]" won't show up in your Map Name Popup # windows. #============================================================================== # ? Game Database Setup #------------------------------------------------------------------------------ # This script, by defult, uses the following game variables and switches: # Database Variables: # [1] The Current Time # [2] The Current Second # [3] The Current Minute # [4] The Current Hour # [5] The Current Day # [6] Name of the Current Day (abbreviated) # [7] The Current Day index in one week (0-6) a week starts from sunday # [8] The Current Month # [9] The Current Month's name (abbreviated) # [10]The Current Day Id in this Month (1-32,or 1-30,or 1-29) # [11]The Current Year # [12]Season's name # [13]Weather's Name # [14]Weather Id, 0 is clear weather.. # Database Switches # [1] ON during night hours (2200-0400)(10pm-4am) # [2] ON during dawn hours (0500-0800)( 5am-8am) # [3] ON during daytime hours (0900-1800)( 9am-6pm) # [4] ON during sunset hours (1900-2100)( 7pm-9pm) # [5] ON during spring season # [6] ON during summer season # [7] ON during fall season # [8] ON during winter season #==============================================================================
#============================================================================== # Stores variables and user defined settings for the time system. #============================================================================== module KTS #----------------------------------------------------------------------- # Settings for Time Periods #----------------------------------------------------------------------- T1 = [ 0,4 ] # Night # Sets time periods for tinting effects T2 = [ 5,8 ] # Dawn # [Start Hour, End Hour] for time period T3 = [ 9,15] # Day # Use 24-hour values for time periods T4 = [16,17] # Sunset T5 = [18,24] # Night # <- Ex: Night is between 23:00 and 24:00 #----------------------------------------------------------------------- # Settings for Output to Game Variables option. #----------------------------------------------------------------------- # Set this to true to output the current time to game variables. DATABASE_OUTPUT = true # Game Variable to be used for time output. TIME = 1 #(Time in string format. Ex: "2:48 AM" or "02:48") SECONDS = 2 # 1 to 59 MINUTES = 3 # 1 to 59 HOURS = 4 # 1 to 24 DAYS = 5 # 1 to 366 DAYNAME = 6 # Sun, Mon, etc.. WEEKDAY = 7 # 0 to 6 (Day index in one week) MONTH = 8 # 1 to 12 MONTHNAM= 9 # Jan, Feb, May, etc.. MONTHDAY= 10# 1 to 31 YEAR = 11# 1994, 2009, etc SEASON = 12# Season Name (Summer, Spring, ETC) WEATHERN= 13# Weather's name WEATHER = 14# Weather Id, 0 is clear weather # Game Switches to be used for time output. NIGHT = 1 # This switch is on during night hours (2200-0400)(10pm-4am) DAWN = 2 # This switch is on during dawn hours (0500-0800)( 5am-8am) DAY = 3 # This switch is on during daytime hours (0900-1800)( 9am-6pm) SUNSET = 4 # This switch is on during sunset hours (1900-2100)( 7pm-9pm) SPRING = 5 # This switch is on during spring season SUMMER = 6 # This switch is on during summer season FALL = 7 # This switch is on during fall season WINTER = 8 # This switch is on during winter season #----------------------------------------------------------------------- # Settings for time controlled screen toning #----------------------------------------------------------------------- # True will enable screen toning to be used by the script. USE_TONE = true # Sets the duration of tone changes (in frames) FADE_LENGTH = 240 # Defines tones to be used in the corresponding time periods defined above. # RED, GREEN, BLUE, GREY C1 = Tone.new(-187, -119, -17, 68) C2 = Tone.new( 17, -51, -102, 0) C3 = Tone.new( 0, 0, 0, 0) C4 = Tone.new( -68, -136, -34, 0) C5 = Tone.new(-187, -119, -17, 68) # Defines anti-tones A1 = Tone.new( 187, 119, 17, -68) A2 = Tone.new( -17, 51, 102, 0) A3 = Tone.new( 0, 0, 0, 0) A4 = Tone.new( 68, 136, 34, 0) A5 = Tone.new( 187, 119, 17, -68) #----------------------------------------------------------------------- # MOD #----------------------------------------------------------------------- #----------------------------------------------------------------------- # Settings for season periods #----------------------------------------------------------------------- S1 = [ 1,3 ] # Spring # Sets month periods for season system S2 = [ 4,6 ] # Summer # [Start Month, End Month] for time period S3 = [ 7,9 ] # Fall # S4 = [10,12] # Winter # <- Ex: Winter is between 10th - 12th (Oct - Des) # Use automatic weather? WEATHER_SYSTEM = true # Sets the duration of weather changes (in frames) WEATHER_LENGTH = 240 # Time before changing weather (in hours) WEATHER_COOLDOWN = 3 # Weather names (Must be the same order as weather's Id) adds as many as required # 0 1 2 3 WEATHER_NAME = ["Clear", "Rain" , "Storm" , "Snowy"] # VX default only have these 3 #----------------------------------------------------------------------- # Settings for possible weather # To add more weathers, just add more weather ids there # ex = W[#] = [ WeatherId, .....] # S[#] means, season number # # Weathers only occurs when entering map with [KTS] on it's name. # Those weathers will be randomly occurs, but snowy weather only spawn # on Winter #----------------------------------------------------------------------- W = {} W[1] = [0, 1, 2 ] # [ WeatherId, .....] W[2] = [0, 1, 2 ] # [ WeatherId, .....] W[3] = [0, 1, 2 ] # [ WeatherId, .....] W[4] = [0, 1, 3 ] # [ WeatherId, .....] #----------------------------------------------------------------------- # Settings for weather bgs # WeatherId => "filename", file must be in Audio/BGS/ folder #----------------------------------------------------------------------- WEATHERSOUND_OK = true # If true, setup the BGS on line 385 # Remember. BGS only changes when you enter/exit a map, but weather can change # even if you stay inside a map for a long time.... end
#============================================================================== # Core Time System Engine (MODDED) #============================================================================== class Kylock_Time_System # sets instance variables def initialize $kts_map_data = load_data("Data/MapInfos.rvdata") @event_offset = (Time.now.strftime("%H").to_i * 3600) + (Time.now.strftime("%w").to_i * 86400) $kts_event_tone = false $kts_event_weather = false $kts_battle_tone = true $kts_anti_tone = Tone.new(0,0,0,0) @startingweatherdelay = 0 @curweather = 0 @played = false end # Computes current time and updates variables if used def update if !@kts_stop # for scripters @total_seconds = Graphics.frame_count + @event_offset @total_minutes = @total_seconds / 60 @total_hours = @total_minutes / 60 @total_days = @total_hours / 24 @total_weeks = @total_days / 7 @total_months = @total_weeks / 4 @total_years = @total_months/12 # @seconds = Time.now.sec @minutes = Time.now.min @hours = Time.now.hour @days = Time.now.strftime("%j").to_i @weekday = Time.now.strftime("%w").to_i @month = Time.now.strftime("%m").to_i @monthname = Time.now.strftime("%b") @monthday = Time.now.strftime("%d") @year = Time.now.strftime("%Y").to_i update_tint update_weather if KTS::DATABASE_OUTPUT $game_variables[KTS::TIME] = getTime end end end # def update_variables $game_variables[KTS::SECONDS] = @seconds $game_variables[KTS::MINUTES] = @minutes $game_variables[KTS::HOURS] = @hours $game_variables[KTS::DAYS] = @days $game_variables[KTS::DAYNAME] = getDayName $game_variables[KTS::WEEKDAY] = @weekday $game_variables[KTS::MONTH] = @month $game_variables[KTS::MONTHNAM] = @monthname $game_variables[KTS::YEAR] = @year if KTS::WEATHER_SYSTEM == true $game_variables[KTS::WEATHERN] = getWeatherName $game_variables[KTS::WEATHER] = @weather end $game_variables[KTS::SEASON] = getSeasonName $game_variables[KTS::MONTHDAY] = @monthday end # def update_switches if @period == 1 || @period == 5 $game_switches[KTS::NIGHT] = true else $game_switches[KTS::NIGHT] = false end if @period == 2 $game_switches[KTS::DAWN] = true else $game_switches[KTS::DAWN] = false end if @period == 3 $game_switches[KTS::DAY] = true else $game_switches[KTS::DAY] = false end if @period == 4 $game_switches[KTS::SUNSET] = true else $game_switches[KTS::SUNSET] = false end end # def update_season_swithces if @month >= KTS::S1[0] and @month <= KTS::S1[1] @speriod = 1 $game_switches[KTS::SPRING] = true else $game_switches[KTS::SPRING] = false end if @month >= KTS::S2[0] and @month <= KTS::S2[1] @speriod = 2 $game_switches[KTS::SUMMER] = true else $game_switches[KTS::SUMMER] = false end if @month >= KTS::S3[0] and @month <= KTS::S3[1] @speriod = 3 $game_switches[KTS::FALL] = true else $game_switches[KTS::FALL] = false end if @month >= KTS::S4[0] and @month <= KTS::S4[1] @speriod = 4 $game_switches[KTS::WINTER] = true else $game_switches[KTS::WINTER] = false end end #----------------------------------------------------------------------- # Script Support/Misc Functions (MODDED) #----------------------------------------------------------------------- def getTime time = Time.now.strftime("%H:%M %p") return time end def getSeasonName sname = "Spring" if @speriod == 1 sname = "Summer" if @speriod == 2 sname = "Fall" if @speriod == 3 sname = "Winter" if @speriod == 4 return sname end def getMonthName monthname = Time.now.strftime('%b') return monthname end def getDayName weekday = Time.now.strftime('%a') return weekday end def getWeatherName weathername = KTS::WEATHER_NAME[@weather] return weathername end
#----------------------------------------------------------------------- # Screen Tone Functions #----------------------------------------------------------------------- def update_tint(duration = KTS::FADE_LENGTH) return if $BTEST if KTS::USE_TONE && !$kts_event_tone && $kts_map_data[$game_map.map_id].outside_tint? if @hours >= KTS::T1[0] and @hours <= KTS::T1[1] @period = 1 screen.start_tone_change(KTS::C1,duration) $kts_anti_tone = KTS::A1 elsif @hours >= KTS::T2[0] and @hours <= KTS::T2[1] @period = 2 screen.start_tone_change(KTS::C2,duration) $kts_anti_tone = KTS::A2 elsif @hours >= KTS::T3[0] and @hours <= KTS::T3[1] @period = 3 screen.start_tone_change(KTS::C3,duration) $kts_anti_tone = KTS::A3 elsif @hours >= KTS::T4[0] and @hours <= KTS::T4[1] @period = 4 screen.start_tone_change(KTS::C4,duration) $kts_anti_tone = KTS::A4 elsif @hours >= KTS::T5[0] and @hours <= KTS::T5[1] @period = 5 screen.start_tone_change(KTS::C5,duration) $kts_anti_tone = KTS::A5 end else # no tone if indoors if !$kts_map_data[$game_map.map_id].outside_tint? screen.start_tone_change(Tone.new(0,0,0,0),duration) end end end # Set weather def setweather(duration) if ((@startingweatherdelay - @hours) >= KTS::WEATHER_COOLDOWN) or ((@startingweatherdelay - @hours) <= -KTS::WEATHER_COOLDOWN) @startingweatherdelay = Time.now.hour the_weatherset = KTS::W[@speriod] @curweather = the_weatherset[rand(KTS::W[@speriod].length)] @weather = @curweather else @weather = @curweather end $game_map.screen.weather(@weather, 9 , duration) end
#----------------------------------------------------------------------- # Season/weather update #----------------------------------------------------------------------- def update_weather(duration = KTS::WEATHER_LENGTH) return if $BTEST if KTS::WEATHER_SYSTEM && !$kts_event_weather && $kts_map_data[$game_map.map_id].outside_tint? if @month >= KTS::S1[0] and @month <= KTS::S1[1] @speriod = 1 elsif @month >= KTS::S2[0] and @month <= KTS::S2[1] @speriod = 2 elsif @month >= KTS::S3[0] and @month <= KTS::S3[1] @speriod = 3 elsif @month >= KTS::S4[0] and @month <= KTS::S4[1] @speriod = 4 end setweather(duration) else # no weather if indoors if !$kts_map_data[$game_map.map_id].outside_tint? Audio.bgs_stop #Stop BGS $game_map.screen.weather(0, 0, 0) end end end
def screen if $game_temp.in_battle return $game_troop.screen else return $game_map.screen end end
# Extra Feature; Change BGS def start_bgs return if !$kts_map_data[$game_map.map_id].outside_tint? if $kts_map_data[$game_map.map_id].outside_tint? # This is night BGS, disabled in this MOD #~ if $game_switches[KTS::NIGHT] == true #~ Audio.bgs_play("Audio/BGS/Forest", 80, 100) #~ elsif $game_switches[KTS::DAWN] or $game_switches[KTS::SUNSET] #~ Audio.bgs_play("Audio/BGS/Forest", 30, 100) #~ else #~ Audio.bgs_stop #~ end if KTS::WEATHER_SYSTEM == true if KTS::WEATHERSOUND_OK == true if @weather == 1 Audio.bgs_play("Audio/BGS/Rain", 70, 100) elsif @weather == 2 Audio.bgs_play("Audio/BGS/Storm", 70, 100)
# ADD MORE IF YOU WANT to play BGS when weather with Id @weather occurs! # Like this : # elsif @weather == Id # Audio.bgs_play("Audio/BGS/SomeBGS", 70, 100) else Audio.bgs_stop end end end end end
end
class Spriteset_Map #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- alias kts_initialize initialize def initialize $kts.update_switches if KTS::DATABASE_OUTPUT $kts.update_variables if KTS::DATABASE_OUTPUT $kts.update_season_swithces if KTS::DATABASE_OUTPUT kts_initialize end end
#============================================================================== # Instantly updates screen tone when a new map is loaded. #============================================================================== class Game_Map alias kts_setup setup def setup(map_id) kts_setup(map_id) $kts_event_tone = false $kts.update $kts.update_tint(0) $kts.update_weather(0) if KTS::WEATHER_SYSTEM $kts.start_bgs end end
#============================================================================== # Instantly updates screen tone when a battle starts. #============================================================================== class Spriteset_Battle alias kts_create_battleback create_battleback def create_battleback $kts.update_tint(0) kts_create_battleback end end
#============================================================================== # Temporarily disables auto-toning if an event tints the screen. #============================================================================== class Game_Interpreter alias kts_Interpreter_command_223 command_223 def command_223 $kts_event_tone = true kts_Interpreter_command_223 end alias kts_Interpreter_command_236 command_236 def command_236 $kts_event_weather = true kts_Interpreter_command_226 end end
#============================================================================== # Integrates the Time System into the Game System. #============================================================================== class Game_System # inits a KTS object alias kts_initialize initialize def initialize $kts=Kylock_Time_System.new kts_initialize end # Updates kts every game frame alias kts_update update def update $kts.update kts_update end end
#============================================================================== # Scans Map Names for Toning #============================================================================== class RPG::MapInfo def name # Definition prevents location scripts from reading anything within return @name.gsub(/\[.*\]/) {""} # brackets, including the brackets end def original_name return @name end def outside_tint? return @name.scan(/\[KTS\]/).size > 0 # old regexp: return @name.scan(/[\KTS]/).size > 0 end end
#============================================================================== # Sets up the time window for the menu. (MODDED) #============================================================================== class Window_KTS < Window_Base def initialize(x, y) super(x, y, 160, WLH+32) refresh end def refresh self.contents.clear self.contents.draw_text(0, -6, 120, 32,$kts.getDayName+" "+$kts.getTime, 2) end def update super $kts.update self.contents.clear self.contents.draw_text(0, -6, 120, 32, $kts.getDayName+" "+$kts.getTime, 2) end end
#============================================================================== # Adds the time window to the menu. #============================================================================== class Scene_Menu < Scene_Base alias kts_start start def start kts_start @kts_window = Window_KTS.new(0,304) end alias kts_terminate terminate def terminate kts_terminate @kts_window.dispose end alias kts_update update def update kts_update @kts_window.update end end
#============================================================================== # Saves and Loads game time to/from save game file. #============================================================================== class Scene_File alias kts_write_save_data write_save_data def write_save_data(file) kts_write_save_data(file) Marshal.dump($kts, file) end alias kts_read_save_data read_save_data def read_save_data(file) kts_read_save_data(file) $kts = Marshal.load(file) end end
Credit only to Kylock for the great script!
This post has been edited by reijubv: May 29 2009, 08:57 PM
Group: Member
Posts: 9
Type: None
RM Skill: Beginner
For this one, is it pretty easy to turn off the lights when it becomes day time? Im using the orginal script and the events that triggers the events for Lighting Effect 1.2 doesnt shut off the lights when its morning and day time.
Group: Member
Posts: 27
Type: Event Designer
RM Skill: Skilled
QUOTE (AllPaoTeam @ May 28 2009, 05:44 AM)
For this one, is it pretty easy to turn off the lights when it becomes day time? Im using the orginal script and the events that triggers the events for Lighting Effect 1.2 doesnt shut off the lights when its morning and day time.
iyeah its pretty easy, this script uses swiches too you know! like i just use a an empty event and then when the night swich gets "on" the new "light" page comes active, it works for me.... only it dosent work until you open the menu once....
Group: Member
Posts: 2
Type: Developer
RM Skill: Intermediate
Actually, this is a great script, but I still have a doubt.
I read the script over several times, and made some slight modifications to play different BGMs at each time output (Night, Day, Dawn, Sunset), making it feel a bit like Animal Crossing, but the problem I have is, how exactly do I code my events to appear in a specific day?
Like for example:
I want a NPC to appear in a store selling his own wares in Monday. A girl walking out at night in a Tuesday. Or a group of people walking around in Friday Sunset.
Another issue I'm having with it is that at night, I can't even make lightbulbs shine, since the screen's tone darkens everything. Is there a way to make NPCs or Events be unnaffected by the screen tone?
This post has been edited by Bubbleman: Jun 7 2009, 09:26 PM
Group: Revolutionary
Posts: 168
Type: Artist
RM Skill: Advanced
You can use variables, see demo on how to use the variables... to setup bgm/bgs, you can scroll down (I forgot wich line) in the script, there's a place for scripters to set bgs/bgm... ( bgs/bgm won't be played unless player was transfered to other map...)
Group: Member
Posts: 2
Type: Developer
RM Skill: Intermediate
QUOTE (reijubv @ Jun 8 2009, 04:08 AM)
You can use variables, see demo on how to use the variables... to setup bgm/bgs, you can scroll down (I forgot wich line) in the script, there's a place for scripters to set bgs/bgm... ( bgs/bgm won't be played unless player was transfered to other map...)
After spending around an hour with trial and errors, I finally got it to work without any problems, so far. It's a great script with lots of potential. However, is there a way to make the [KTS] tagged map to have different songs for each switch? I used a Common Event call, but it needs to be called every single time you transfer into the map, which isn't bad, but a faster method would be better.
This post has been edited by Bubbleman: Jun 9 2009, 11:51 AM
Group: Member
Posts: 2
Type: Developer
RM Skill: Beginner
When I try to go into the menu, there is an error that appears stating: "Unable to find file Graphic/Pictures/Timer"
Now as per the threads above and in the script, there is no need for a picture/timer.
What do I do?
By the way the script is great otherwise.
***Edit*** Never mind, I figured it out. I had forgotten that I added a FF IX Menu script to the game and I did not port everything in.
***Edit 2***** Below are 4 pics showing the new problem, I am not able to get a light to turn on or off at a certain time. reijubv as I wrote the pics are here, so plaese help if able, anyone.
Thanks in advance.
This post has been edited by darkt6: Aug 1 2009, 07:52 PM
Attached File(s)
before.png ( 329.44K )
Number of downloads: 24 After.png ( 330.08K )
Number of downloads: 13 page_one.png ( 236.13K )
Number of downloads: 12 page_2.png ( 210.88K )
Number of downloads: 12