Code:
#==============================================================================
# ** Window_PlayTime + Day & Night Settings Script
# Window_PlayTime Add-on
# modified by shadowball
#
# On the Menu scene you'll see the current in-game day and time...
#==============================================================================
class Window_PlayTime < Window_Base
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
self.contents.clear
@total_sec = Graphics.frame_count / Graphics.frame_rate
day = @total_sec / 60 / 24 % 7
hour = @total_sec / 60 % 24
minute = @total_sec % 60
text = sprintf("%02d:%02d", hour, minute)
self.contents.font.color = system_color
shb_day = 'Sunday' if day == 0
shb_day = 'Monday' if day == 1
shb_day = 'Tuesday' if day == 2
shb_day = 'Wednesday' if day == 3
shb_day = 'Thursday' if day == 4
shb_day = 'Friday' if day == 5
shb_day = 'Saturday' if day == 6
shb_weekday = shb_day
self.contents.draw_text(0, 0, 120, 32, shb_weekday, 0)
self.contents.font.color = normal_color
self.contents.draw_text(8, 32, 120, 32, text, 2)
end
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#==============================================================================
# * Scene_Map - Modified
# modified by shadowball
#
# Screen tone will change depending on the in-game play time automatically
#==============================================================================
class Scene_Map
alias shb_map_up update
def update
@total_sec = Graphics.frame_count / Graphics.frame_rate
@shb_hour = @total_sec / 60 % 24
if @shb_hour < 5 || @shb_hour > 18 # 7 p.m. - 5 a.m.
$game_screen.start_tone_change(Tone.new(-120, -120, -120, 0), 1)
elsif @shb_hour > 4 && @shb_hour < 7 # 5 a.m. - 7 a.m.
$game_screen.start_tone_change(Tone.new(-40, -40, 0, 0), 1)
elsif @shb_hour > 6 && @shb_hour < 16 # 7 a.m. - 4 p.m.
$game_screen.start_tone_change(Tone.new(0, 0, 0, 0), 1)
elsif @shb_hour > 15 && @shb_hour < 19 # 4 p.m. - 7 p.m.
$game_screen.start_tone_change(Tone.new(30, 10, 0, 0), 1)
end
shb_map_up
end
end
#=======================================================
# * Game_System Add-on v 1.0
# by shadowball
# 08.02.2008
#
# You can set the time in minutes, hours, days
# Syntax: $game_system.set_time(0, 30, 2, 3)
#=======================================================
class Game_System
def set_time(alter = 0, minute = 0, hour = 0, day = 0)
if minute >= 0
if minute >= 60
minute = 59
end
set_min = Graphics.frame_rate * minute
end
if hour >= 0
if hour >= 24
hour = 23
end
set_hour = Graphics.frame_rate * 60 * hour
end
if day >= 0
if day >= 31
day = 30
end
set_day = Graphics.frame_rate * 60 * 24 * day
end
case alter
when 0 # sets the time
Graphics.frame_count = 0 + set_day + set_hour + set_min
when 1 # adds the hours, minutes you specified to the current in-game playtime
Graphics.frame_count = Graphics.frame_count + set_day + set_hour + set_min
when 2 # this one does exactly the opposite...
Graphics.frame_count = Graphics.frame_count - set_day - set_hour - set_min
end
end
end