Group: Member
Posts: 41
Type: Artist
RM Skill: Intermediate
Alright im using Kylock's Time System and cant figure out how to setup screen tinting. If anyone can help me please do, i'll post what my script looks like. Its working from Mr. Mo's ABS system along with several other scripts.
Script
#========================================================================= ===== # Kylock's Time System #============================================================================== # Kylock # Version 1.3 # 10-22-2006 #------------------------------------------------------------------------------ # Based in small parts from Dubealex's ATS and VERY small parts of # mikah's Time Day/Night System. #============================================================================== # What it does! # Game Time will be displayed in the Play Time window. # Current day will be displayed in the Steps Window # # Script assumes 1m=60s 1h=60m 1d=24h # If you use game variables, hours are stored in the 24-hr format # Also note that time CANNOT be controlled by setting the variables, they are # updated(constantly) only. #============================================================================== # To adjust game time from the game (commands identical to Dube's ATS): # "Script: $kts.hours(5)" <- Advances time by 5 hours # "Script: $kts.hours(-5)" <- Rewinds time by 5 hours # Available clock adjustment methods: # $kts.stop - Stops time (can be used for cutscenes) # $kts.go - Resumes Time (if time is not stopped, no effect) # $kts.sec(n) - skips secs # Note that while the clock still appears to run # $kts.min(n) - skips nims # after $kts.stop, when you execute $kts.go, it will # $kts.hours(n)-skips hrs # revert to the time when it was stopped. # $kts.days(n) - skips days # $kts.inn_rest(n) - Advances the clock FORWARD to time specified (use 24-hour notation) # Example: It's 06:08 => $kts.inn_rest(7) => Time is now 07:00 same day # Example: It's 06:08 => $kts.inn_rest(6) => Time is now 06:00 the next day # Could be used for anything, but practically limited to immediate 24 hours. # .inn_rest may also cause a couple seconds of lag when used on slower # systems. #============================================================================== # Default varialbes for time output: # Variables: [1] Clock Seconds # [2] Clock Minutes # [3] Clock Hours # [4] Clock Days # [5] Day Name (for events based on day of week) # To control screen tinting, place[*] in the name of your outdoor maps. This # will enable tinting. #============================================================================== # Release Notes: # # 1.3 - Several bugs related to the auto-tinting feature have been fixed # thanks to the dilliget whining- er I mean bug reporting of # Mike Portnoy on the rmxp.org forums. =P # # 1.2 - Modified the tint code so that there would be smoother tinting during # transitions from indoor to outdoor[*] areas and vice versa. You # will no longer see situations where you see the normal tone, then # a quick switch to the outdoor tone. It's much smoother and less # jittery looking now. # - Added global variable $kts_current_tone that stores the current tone # formatted as: Tone.new(x,x,x,x) This is useful for setting the tone # for pictures and sprites in outdoor areas for uniformity purposes. # - Fixed a bug that completely killed event driven tinting when indoors. # # 1.1 - Removed dependancy on a game switch to determine indoor/outdoor area # status. Now you simply have to add "[*]" to the name of outdoor # areas. # # 1.0 - Original release. #==============================================================================
$data_map = load_data("Data/MapInfos.rxdata")
class Kylock_Time
#======================== # Configuration Settings #======================== def initialize @start_clock = 1 # in hours (24-hr format) - First hour of your game @start_day = 0 # in days - First day of your game @clock_speed = 30 # in frames (default: 30) - 0 = real time @clock_ampm = true # time display setting: true = 12 hr clock
#=========================== # Script-controlled Tinting #=========================== # To use auto-tinting, place "[*]" in tht name of your outdoors maps. # Example: "Outdoors[*]" will get tinting, but "Outdoors" or # "Outdoors[BLAH]" will not. $tint_during_battle = true # If set to false, battles will have no tint # may slightly reduce battle lag
@t1 = [0, 4] # Early Morning # Sets time periods for tinting effects @t2 = [5, 11] # Morning # [Start Hour, End Hour] for time period @t3 = [12, 18] # Day # Use 24-hour values for time periods @t4 = [19, 22] # Evening @t5 = [23, 24] # Night # <- Ex: Night is between 23:00 and 24:00
@c1 = [-187, -119, -17, 68, 20] # Defines tints to be used in time periods @c2 = [17, -51, -102, 0, 20] # defined above. @c3 = [0, 0, 0, 0, 20] # [Red, Green, Blue, Grey, Time(in frames)] @c4 = [-68, -136, -34, 0, 20] @c5 = [-187, -119, -17, 68, 20]
#========================================== # If you want custom day names, edit away! #========================================== @day_name = ["Dies Solis","Dies Lunae","Dies Martis","Dies Mercurii","Dies Jovis","Dies Jovis","Dies Saturni"]
#==================================== # Time System: Game Variable Options #==================================== @use_vars = true # assign time to game play variables @sec_var = 1 # Variable to which to store Seconds @min_var = 2 # Variable to which to store Minutes @hr_var = 3 # Variable to which to store Hours (stored using 24-hr format) @day_var = 4 # Variable to which to store Days @weekday_var = 5 # Variable to which to store Name of the Day
#============================================== # Used for time adjustments called from events #============================================== @game_time_offset = (@start_clock * 3600) + (@start_day * 86400) $kts_tint_update_pause = true end
#======================== # End of Configuration #========================
def update # Calculate total number of seconds @total_seconds = (Graphics.frame_count / (Graphics.frame_rate - @clock_speed)) + @game_time_offset
# Update Game Variables if used if @use_vars $game_variables[@sec_var] = @clock_seconds $game_variables[@min_var] = @clock_minutes $game_variables[@hr_var] = @clock_hours $game_variables[@day_var] = @clock_days $game_variables[@weekday_var] = today_name end end
def update_tint #updates screen tinting if $data_map[$game_map.map_id].outside_tint? and $kts_tint_update_pause == false if @clock_hours >= @t1[0] and @clock_hours <= @t1[1] $game_screen.start_tone_change(Tone.new(@c1[0],@c1[1],@c1[2],@c1[3]),@c1[4]) $kts_current_tone = Tone.new(@c1[0],@c1[1],@c1[2],@c1[3]) elsif @clock_hours >= @t2[0] and @clock_hours <= @t2[1] $game_screen.start_tone_change(Tone.new(@c2[0],@c2[1],@c2[2],@c2[3]),@c2[4]) $kts_current_tone = Tone.new(@c2[0],@c2[1],@c2[2],@c2[3]) elsif @clock_hours >= @t3[0] and @clock_hours <= @t3[1] $game_screen.start_tone_change(Tone.new(@c3[0],@c3[1],@c3[2],@c3[3]),@c3[4]) $kts_current_tone = Tone.new(@c3[0],@c3[1],@c3[2],@c3[3]) elsif @clock_hours >= @t4[0] and @clock_hours <= @t4[1] $game_screen.start_tone_change(Tone.new(@c4[0],@c4[1],@c4[2],@c4[3]),@c4[4]) $kts_current_tone = Tone.new(@c4[0],@c4[1],@c4[2],@c4[3]) elsif @clock_hours >= @t5[0] and @clock_hours <= @t5[1] $game_screen.start_tone_change(Tone.new(@c5[0],@c5[1],@c5[2],@c5[3]),@c5[4]) $kts_current_tone = Tone.new(@c5[0],@c5[1],@c5[2],@c5[3]) end else $kts_current_tone = Tone.new(0,0,0,0) end end
def instant_tint #updates screen tinting if $data_map[$game_map.map_id].outside_tint? and $kts_tint_update_pause == false $kts_manual_tone = false if @clock_hours >= @t1[0] and @clock_hours <= @t1[1] $game_screen.start_tone_change(Tone.new(@c1[0],@c1[1],@c1[2],@c1[3]),0) $kts_current_tone = Tone.new(@c1[0],@c1[1],@c1[2],@c1[3]) elsif @clock_hours >= @t2[0] and @clock_hours <= @t2[1] $game_screen.start_tone_change(Tone.new(@c2[0],@c2[1],@c2[2],@c2[3]),0) $kts_current_tone = Tone.new(@c2[0],@c2[1],@c2[2],@c2[3]) elsif @clock_hours >= @t3[0] and @clock_hours <= @t3[1] $game_screen.start_tone_change(Tone.new(@c3[0],@c3[1],@c3[2],@c3[3]),0) $kts_current_tone = Tone.new(@c3[0],@c3[1],@c3[2],@c3[3]) elsif @clock_hours >= @t4[0] and @clock_hours <= @t4[1] $game_screen.start_tone_change(Tone.new(@c4[0],@c4[1],@c4[2],@c4[3]),0) $kts_current_tone = Tone.new(@c4[0],@c4[1],@c4[2],@c4[3]) elsif @clock_hours >= @t5[0] and @clock_hours <= @t5[1] $game_screen.start_tone_change(Tone.new(@c5[0],@c5[1],@c5[2],@c5[3]),0) $kts_current_tone = Tone.new(@c5[0],@c5[1],@c5[2],@c5[3]) end else if $kts_manual_tone == false $game_screen.start_tone_change(Tone.new(0,0,0,0),0) $kts_current_tone = Tone.new(0,0,0,0) end end end
# Returns the name of the current day def today_name weekday = (@total_days % @day_name.length) return @day_name[weekday] end
# Returns the number of the current day def game_days return @total_days.to_s end
# Formats the time string def time if @clock_ampm # Formats 12-hour clock if @clock_hours > 12 clock_hours_ampm = @clock_hours - 12 if clock_hours_ampm > 9 time = sprintf("%02d:%02d" + " PM", clock_hours_ampm, @clock_minutes) else time = sprintf("%01d:%02d" + " PM", clock_hours_ampm, @clock_minutes) end return time else if @clock_hours > 9 time = sprintf("%02d:%02d" + " AM", @clock_hours, @clock_minutes) else time = sprintf("%01d:%02d" + " AM", @clock_hours, @clock_minutes) end return time end else # Formats 24-hour clock time = sprintf("%02d:%02d" + " ", @clock_hours, @clock_minutes) return time end end
# Manual clock adjustment methods def stop #capture stopping point @time_stopped = @total_seconds end
def go #determine time passage while time was stopped and compensate using offset @total_seconds = (Graphics.frame_count / (Graphics.frame_rate - @clock_speed)) + @game_time_offset @game_time_offset -= @total_seconds - @time_stopped end
def sec(sec = 0) @game_time_offest += sec end
def min(min = 0) @game_time_offset += min * 60 end
def hours(hours = 0) @game_time_offset += hours * 3600 end
def days(days = 0) @game_time_offset += days * 86400 end
def inn_rest(inn_time = 0) while @clock_hours != inn_time @game_time_offset += 1 total_seconds = (Graphics.frame_count / (Graphics.frame_rate - @clock_speed)) + (@start_clock * 3600) + (@start_day * 86400) + @game_time_offset @clock_hours = total_seconds / 3600 % 24 end end end
class Interpreter #-------------------------------------------------------------------------- # * Change Screen Color Tone #-------------------------------------------------------------------------- alias kts_Interpreter_command_223 command_223 def command_223 $kts_manual_tone = false kts_Interpreter_command_223 end end
#============================================================================== # Creates the kylock_time object #============================================================================== class Scene_Title $kts=Kylock_Time.new end
#============================================================================== # Updates the clock using Game_System #============================================================================== class Game_System alias kts_game_system_update update def update kts_game_system_update $kts.update end end
#============================================================================== # Initializes new map tinting using Game_Map #============================================================================== class Game_Map alias kts_game_map_setup setup def setup(map_id) kts_game_map_setup(map_id) $kts.update $kts.instant_tint end end
#============================================================================== # Updates screen tinting using Scene_Map #============================================================================== class Scene_Map alias kts_scene_map_update update def update kts_scene_map_update $kts.update_tint end end
class Scene_Map alias kts_call_battle call_battle def call_battle if $tint_during_battle == true $kts_tint_update_pause = true $game_screen.start_tone_change(Tone.new(0,0,0,0),0) end kts_call_battle end end
class Scene_Battle alias kts_battle_end battle_end def battle_end(result) $kts_tint_update_pause = false kts_battle_end(result) end end
#============================================================================== # Scans Map Names for Tinting #============================================================================== 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(/[\*]/).size > 0 end end
#============================================================================== # Changes the Play Time Window to Game Time! #============================================================================== class Window_PlayTime < Window_Base def refresh self.contents.clear self.contents.font.color = system_color self.contents.draw_text(4, 0, 120, 32, "Game Time") $kts.update self.contents.font.color = normal_color self.contents.draw_text(4, 32, 120, 32, $kts.time, 2) end end
#============================================================================== # Changes Steps Window to Day #============================================================================== class Window_Steps < Window_Base def refresh self.contents.clear self.contents.font.color = system_color self.contents.draw_text(4, 0, 120, 32, "Day") self.contents.font.color = normal_color self.contents.draw_text(4, 0, 120, 32, $kts.game_days, 2) self.contents.draw_text(4, 32, 120, 32, $kts.today_name, 2) end end
#============================================================================== # Saves time to save game file #============================================================================== class Scene_Save alias kts_write_save_data write_save_data def write_save_data(file) kts_write_save_data(file) Marshal.dump($kts, file) end end
#============================================================================== # Loads time from save game file #============================================================================== class Scene_Load alias kts_read_save_data read_save_data def read_save_data(file) kts_read_save_data(file) $kts = Marshal.load(file) end end
__________________________
Check out my game on my website Ark's Journey - 1% Complete My Free Webs Website
Group: +Gold Member
Posts: 1,520
Type: Scripter
RM Skill: Undisclosed
If you're having the same problems as I just had trying to get it to work, it's quite easy to fix
Setting up
Setting up screen tinting can be done in the script editor, lines 91 - 101 read:
CODE
@t1 = [0, 4] # Early Morning # Sets time periods for tinting effects @t2 = [5, 11] # Morning # [Start Hour, End Hour] for time period @t3 = [12, 18] # Day # Use 24-hour values for time periods @t4 = [19, 22] # Evening @t5 = [23, 24] # Night # <- Ex: Night is between 23:00 and 24:00
@c1 = [-255,-255,-255,255, 20] # Defines tints to be used in time periods @c2 = [17, -51, -102, 0, 20] # defined above. @c3 = [0, 0, 0, 0, 20] # [Red, Green, Blue, Grey, Time(in frames)] @c4 = [-68, -136, -34, 0, 20] @c5 = [-187, -119, -17, 68, 20]
You have ot have 5 sections that make up your day (sorry, that's coded into the script), that first line:
CODE
@t1 = [0, 4]
Means that the first section to your day occurs between midnight and 4am. Similarly, the second line:
CODE
@t2 = [5, 11]
Means that the second section of your day occurs between 5am and 11am (note that all the times must be on the hour, can't have things like 11:30, and the values are in 24hr, so after 12 (midday) is 13 (1pm)).
Next you'll find:
CODE
@c1 = [-255,-255,-255,255, 20]
, well, that's my numbers, but the each of the first three values can range between -255 (completely lacking in that colour) to +255 (saturated in that colour), and represent red, blue and green respectively. The next number is how grey the image is (0 being a normal image, 255 being completely gray-scale). Once again, c1 is the colour of the screen during your first time segment. And the last number is how long it takes to fade to the new colour, in frames. Your game runs at 20 frames per second, so if you tell your game to wait 20 frames, it will wait 1 second. If you set this last value to 40 frames, it will take 2 seconds. If you want to see what the colours look like, it uses the same command as the Event Commands >> Page 2 >> Change Screen Tone Color, and if you look at the evented change tone colour it gives you an idea of what the tones will look like.
The problem I was having was in actually getting the map to show the tone changes!
Running the code
The code will only run on maps that have an asterisk (*) in its name. To change the name of your map, while in the map editor, go along the left 3/4 of the way down it has your maps. Right click on one and select Map Properties, and you can change the name (for example, my map is now called MAP001* so it includes an asterisk). The other thing you need to do is to make an event, and have it run the script (In the list of events, page 3, last item is Script):
CODE
$kts_tint_update_pause = false
That switch is designed to be changed when you run a cutscene. If you want to update the tint, you run
CODE
$kts_tint_update_pause = false
But if you want to force your own tint on the game, then you can run:
CODE
$kts_tint_update_pause = true
and the script will stop forcing its own tint on the map
__________________________
K.I.S.S. Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.