Linkforce~
Member
I recently started using Trickster's Time System scripts found here.
Was kinda wondering if the HUD system, the thing that makes a little window at the top of the screen, could display more than just the time that has passed.
Right now it shows just the time, like 8:00 PM or 12:00 AM and so on.
What I want it to do though is instead of showing just the time, it should show both what time it is and what day it is (not necessarily what month/year it is since I'm not really using those parts)
Example: "Monday, 12:00 AM" or "Saturday, 7:00 PM"
shadowball made something similar to what I'm looking for here. Except his script changes the play time in the menu, and he uses the actual time and date, not the one generated by the script.
So if it isn't to much trouble, I'd like to request a script-edit to the HUD script so that it shows the Day as well as the Time generated by the Time System Script.
Here's the Time System Script:
And here's the HUD Add-On Script:
Not asking for much. I've been trying to figure out how to do it myself, but it'd help if I knew something about scripting ~.~ (doesn't know crap 'bout scripting ':|)
Thanks in Advance.
Was kinda wondering if the HUD system, the thing that makes a little window at the top of the screen, could display more than just the time that has passed.
Right now it shows just the time, like 8:00 PM or 12:00 AM and so on.
What I want it to do though is instead of showing just the time, it should show both what time it is and what day it is (not necessarily what month/year it is since I'm not really using those parts)
Example: "Monday, 12:00 AM" or "Saturday, 7:00 PM"
shadowball made something similar to what I'm looking for here. Except his script changes the play time in the menu, and he uses the actual time and date, not the one generated by the script.
So if it isn't to much trouble, I'd like to request a script-edit to the HUD script so that it shows the Day as well as the Time generated by the Time System Script.
Here's the Time System Script:
Code:
=begin
==============================================================================
â—â— Trickster's Time System
------------------------------------------------------------------------------
Trickster (tricksterguy@hotmail.com)
Version 2.2
Date 7/13/07
goto rmxp.org for updates/support/bug reports
------------------------------------------------------------------------------
Introduction:
-------------
This script allows your game to have time. Also includes a simple Day Night
System. And Also you can setup events that happen at a certain time
(ex. at 0 to 6 minutes past each hour, or on Tuesday March 20, 2007 at
3:00 PM to 4:00 the same day and year), This script wasn't meant to be an exact
copy of our calendar as it is not accurate
------------------------------------------------------------------------------
Features:
---------
* Simple
* Can Set Time to a certain hour, minute, month, day, year
* Can Speed up or slow down time
* Can Disable Tinting
* Tinting is disabled on inside maps
* Can Setup Initial time
* Can redefine the time system
* Includes a Time HUD
* Can export to regular variables
------------------------------------------------------------------------------
Insrutctions:
-------------
- If you want to disable day night toning completely do this in a call script
$game_time.tone_enabled = false and that will disable it
- To Change the time just call $game_time.(value) = time replace (value) with
either minute, hour, day, month or year and time is the new time
- To Move Time forword just call $game_time.(value) += time replace (value)
with either minute, hour, day, month, or year and time is the time to move
forward by
To Setup A Event's Time Condition:
----------------------------------
- Use an Event Comment that says Time_Setup
- To set the minutes the event is to happen type
start_minute (minute)
end_minute (minute)
and that setups the event to happen starting at start_minute and ending at
end_minute.
- To set the other parameters (hours, days, months, and years) follow the
above but use start_hour and end_hour for hours, start_day and end_day for
days, start_month and end_month for months, and start_year and end_year for
years.
- There are also two other parameters on_day and on_month which checks if it
is on a day.
- New 2.2 a script condition has been added useful for checking if the time
is between for example 2100 and 500 (note this is evaluated in the scope
of the Game_Time class use minutes, hours, days, months, years to get the
respective value of the variable) you may also call methods defined in this
class as the condition.
==============================================================================
=end
#--------------------------------------------------------------------------
# * Begin SDK Log
#--------------------------------------------------------------------------
SDK.log('Time System', 'Trickster', 2.2, '7.13.07')
#--------------------------------------------------------------------------
# Begin SDK Requirement Check
#--------------------------------------------------------------------------
SDK.check_requirements(2.2, [1, 2, 3, 4], ['Map Info'])
#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.enabled?('Time System')
module Time_Setup
#--------------------------------------------------------------------------
# * Minute Length
# - How Many Seconds are in a Minute?
#--------------------------------------------------------------------------
Minute = 2
#--------------------------------------------------------------------------
# * Hour Length
# - How Many Minutes are in a Hour?
#--------------------------------------------------------------------------
Hour = 60
#--------------------------------------------------------------------------
# * Day Length
# - How Many Hours are in a Day?
#--------------------------------------------------------------------------
Day = 24
#--------------------------------------------------------------------------
# * Month Length
# - How Many Days are in a Month?
#--------------------------------------------------------------------------
Month = 30
#--------------------------------------------------------------------------
# * Year Length
# - How Many Months are in a Year?
#--------------------------------------------------------------------------
Year = 12
#--------------------------------------------------------------------------
# * Starting Time
# - Year, Month, Day, Hour, Minute
#--------------------------------------------------------------------------
Time = 2007, 11, 7, 9, 37
#--------------------------------------------------------------------------
# * Days of the Week
#--------------------------------------------------------------------------
Days = %W( Sunday Monday Tuesday Wednesday Thursday Friday Saturday )
#--------------------------------------------------------------------------
# * Months of the Year
#--------------------------------------------------------------------------
Months = %W( Janurary Feburary March April May June July August September
October November December )
#--------------------------------------------------------------------------
# * Time Format
# 0 - HHMM 1 - HH:MM 2 - HH:MM AM / PM (Splits Day Rate in Half)
#--------------------------------------------------------------------------
Time_Format = 2
#--------------------------------------------------------------------------
# * Morning
# - When is it Morning?
# - Default - Defined as 5AM to 12PM
#--------------------------------------------------------------------------
Morning = proc {|hour| hour >= 5 && hour < 12}
#--------------------------------------------------------------------------
# * Afternoon
# - When is it Afternoon?
# - Default - Defined as 12PM to 6PM
#--------------------------------------------------------------------------
Afternoon = proc {|hour| hour >= 12 && hour < 18}
#--------------------------------------------------------------------------
# * Evening
# - When is it Evening?
# - Default - Defined as 6PM to 10PM
#--------------------------------------------------------------------------
Evening = proc {|hour| hour >= 18 && hour < 22}
#--------------------------------------------------------------------------
# * Night
# - When is it Night time?
# - Default - Defined as 10PM to 5AM
#--------------------------------------------------------------------------
Night = proc {|hour| hour >= 22 && hour < 5}
#--------------------------------------------------------------------------
# * Time Effect
# 0 - Wait (In Map Only) 1 - Wait2 (In Map in Battle) 2 - Active
#--------------------------------------------------------------------------
Time_Effect = 2
#--------------------------------------------------------------------------
# * Time Speed (At Start of Game)
#--------------------------------------------------------------------------
Speed = 1
#--------------------------------------------------------------------------
# * Time Stopped (At Start of Game)
#--------------------------------------------------------------------------
Stopped = false
#--------------------------------------------------------------------------
# * Time Stopped During Events
#--------------------------------------------------------------------------
Stopped_Events = true
#--------------------------------------------------------------------------
# * Time Stopped Maps
# - syntax map_id => stopped flag true: stopped time false: otherwise
#--------------------------------------------------------------------------
Stopped_Maps = {}
#--------------------------------------------------------------------------
# * Time Stopped Maps Default
#--------------------------------------------------------------------------
Stopped_Maps.default = false
#--------------------------------------------------------------------------
# * Increase Speed up Time Maps
# - syntax map_id => speed
#--------------------------------------------------------------------------
Speed_Maps = {}
#--------------------------------------------------------------------------
# * Increase Speed up Time Maps Default
#--------------------------------------------------------------------------
Speed_Maps.default = 0
end
class Game_Time
#--------------------------------------------------------------------------
# * Include Time Setup
#--------------------------------------------------------------------------
include Time_Setup
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :minute_length
attr_accessor :stop
attr_accessor :speed
attr_accessor :tone_enabled
attr_accessor :stopped_event
attr_writer :map_stop
attr_writer :map_speed
attr_reader :minutes
attr_reader :hours
attr_reader :days
attr_reader :months
attr_reader :years
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Initialize Minute Length
@minute_length = Minute
# Time Stopped Setup
@stop = Stopped
# Setup Speed Multiplier
@speed = Speed
# Setup Stopped Event
@stopped_event = Stopped_Events
# Setup initial time
@minutes = 0
@hours = 0
@days = 0
@months = 0
@years = 0
# Add Minutes
self.minutes += Time[4]
# Add Hours
self.hours += Time[3]
# Add Days
self.days += Time[2]
# Add Months
self.months += Time[1]
# Add Years
self.years += Time[0]
# Setup Counter
@counter = 0
end
#--------------------------------------------------------------------------
# * Minutes
#--------------------------------------------------------------------------
def minutes=(minutes)
# Set Minutes
@minutes = minutes
# Update Time
update_time
end
#--------------------------------------------------------------------------
# * Hours
#--------------------------------------------------------------------------
def hours=(hours)
# Set Hours
@hours = hours
# Update Time
update_time
end
#--------------------------------------------------------------------------
# * Days
#--------------------------------------------------------------------------
def days=(days)
# Set Days
@days = days
# Update Time
update_time
end
#--------------------------------------------------------------------------
# * Months
#--------------------------------------------------------------------------
def months=(months)
# Set Months
@months = months
# Update Time
update_time
end
#--------------------------------------------------------------------------
# * Years
#--------------------------------------------------------------------------
def years=(years)
# Set Years
@years = years
# Update Time
update_time
end
#--------------------------------------------------------------------------
# * Total Minutes
#--------------------------------------------------------------------------
def total_minutes
return @minutes + total_hours * Hour
end
#--------------------------------------------------------------------------
# * Total Hours
#--------------------------------------------------------------------------
def total_hours
return @hours + total_days * Day
end
#--------------------------------------------------------------------------
# * Total Days
#--------------------------------------------------------------------------
def total_days
return @days + total_months * Month
end
#--------------------------------------------------------------------------
# * Total Months
#--------------------------------------------------------------------------
def total_months
return @months + total_years * Year
end
#--------------------------------------------------------------------------
# * Total Years
#--------------------------------------------------------------------------
def total_years
return @years
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
# Return if time stopped
return if @stop || @map_stop
# Increase Counter
@counter += 1
# Return if not @minute_length seconds passed
return if @counter / Graphics.frame_rate.to_f < @minute_length
# Reset Counter
@counter = 0
# Add One Minute
@minutes += @speed + (@map_speed.nil? ? 0 : @map_speed)
# Update Time
update_time
end
#--------------------------------------------------------------------------
# * Update Time
#--------------------------------------------------------------------------
def update_time
# Add To Amounts
@hours += @minutes / Hour
@days += @hours / Day
@months += @days / Month
@years += @months / Year
# Restrict to [0, Max]
@minutes %= Hour
@hours %= Day
@days %= Month
@months %= Year
end
#--------------------------------------------------------------------------
# * Is Morning?
#--------------------------------------------------------------------------
def is_morning?
return Morning.call(hours)
end
#--------------------------------------------------------------------------
# * Is Afternoon?
#--------------------------------------------------------------------------
def is_afternoon?
return Afternoon.call(hours)
end
#--------------------------------------------------------------------------
# * Is Evening?
#--------------------------------------------------------------------------
def is_evening?
return Evening.call(hours)
end
#--------------------------------------------------------------------------
# * Is Night?
#--------------------------------------------------------------------------
def is_night?
return Night.call(hours)
end
#--------------------------------------------------------------------------
# * Time
#--------------------------------------------------------------------------
def time
# Get Number of Digits
digits = Math.log10(Hour).to_i + 1
# Branch By Time Format
case Time_Format
when 0 #HHMM
time = hours.to_s + sprintf("%0#{digits}d", minutes)
when 1 #HH:MM
time = hours.to_s + sprintf(":%0#{digits}d", minutes)
when 2 #HH:MM AM/PM
# Restrict to [0, Day / 2 - 1]
hour = hours % (Day / 2)
# Set to Day / 2 if 0
hour = Day / 2 if hour == 0
# Get Time
time = hour.to_s + sprintf(":%0#{digits}d", minutes)
# Get AM and PM Text
time += ' ' + (hours >= Day / 2 ? 'PM' : 'AM')
end
# Return String
return time
end
#--------------------------------------------------------------------------
# * Full Time
#--------------------------------------------------------------------------
def full_time
# Get Number of Digits
digits = Math.log10(Hour).to_i + 1
# Get Year String
year = self.years.to_s
# Get Month String
month = current_month
# Get Day of Week
day_name = current_day
# Get Day
day = self.days.to_s
# Branch By Time Format
case Time_Format
when 0 #HHMM
time = hours.to_s + sprintf("%0#{digits}d", minutes)
when 1 #HH:MM
time = hours.to_s + sprintf(":%0#{digits}d", minutes)
when 2 #HH:MM AM/PM
# Restrict to [0, Day / 2 - 1]
hour = hours % (Day / 2)
# Set to Day / 2 if 0
hour = Day / 2 if hour == 0
# Get Time
time = hour.to_s + sprintf(":%0#{digits}d", minutes)
# Get AM and PM Text
time += ' ' + (hours >= Day / 2 ? 'PM' : 'AM')
end
# Return String
return "#{time} #{day_name}, #{month} #{day}, #{year}"
end
#--------------------------------------------------------------------------
# * Current Day
#--------------------------------------------------------------------------
def current_day
return Days[total_days.to_i % Days.size]
end
#--------------------------------------------------------------------------
# * Current Month
#--------------------------------------------------------------------------
def current_month
return Months[total_months.to_i % Months.size]
end
end
class SDK::Scene_Base
#--------------------------------------------------------------------------
# * Main Update
#--------------------------------------------------------------------------
alias_method :trick_time_base_main_update, :main_update
def main_update
# The Usual
trick_time_base_main_update
# Branch By Time Effect
case Time_Setup::Time_Effect
when 0
# Return if not in Scene_Map
return if !$scene.is_a?(Scene_Map)
when 1
# Return if not in Scene_Map or Scene Battle
return if !($scene.is_a?(Scene_Map) || $scene.is_a?(Scene_Battle))
end
# if Time is not nil
unless $game_time.nil?
# If Event Running and Time Stops for events
return if ($game_system.map_interpreter.running? ||
$game_system.battle_interpreter.running?) && $game_time.stopped_event
# Update Time
$game_time.update
end
end
end
class Scene_Map
#--------------------------------------------------------------------------
# * Transfer Player
#--------------------------------------------------------------------------
alias_method :trick_time_map_transfer_player, :transfer_player
def transfer_player
# The Usual
trick_time_map_transfer_player
# Set Map Speed
$game_time.map_speed = Time_Setup::Speed_Maps[$game_map.map_id]
# Set Map Stop
$game_time.map_stop = Time_Setup::Stopped_Maps[$game_map.map_id]
end
end
class Scene_Title
#--------------------------------------------------------------------------
# * Command New Game Game Data
#--------------------------------------------------------------------------
alias_method :trick_time_title_commandnewgame_gamedata, :commandnewgame_gamedata
def commandnewgame_gamedata
# The Usual
trick_time_title_commandnewgame_gamedata
# Create Game Time
$game_time = Game_Time.new
end
#--------------------------------------------------------------------------
# * Command New Game Map Setup
#--------------------------------------------------------------------------
alias_method :trick_time_title_commandnewgame_mapsetup, :commandnewgame_mapsetup
def commandnewgame_mapsetup
# The Usual
trick_time_title_commandnewgame_mapsetup
# Set Map Speed
$game_time.map_speed = Time_Setup::Speed_Maps[$game_map.map_id]
# Set Map Stop
$game_time.map_stop = Time_Setup::Stopped_Maps[$game_map.map_id]
end
end
class Scene_Save
#--------------------------------------------------------------------------
# * Save Data
#--------------------------------------------------------------------------
alias_method :trick_time_save_write_data, :write_data
def write_data(file)
# The Usual
trick_time_save_write_data(file)
# Dump Game Time
Marshal.dump($game_time,file)
end
end
class Scene_Load
#--------------------------------------------------------------------------
# * Save Data
#--------------------------------------------------------------------------
alias_method :trick_time_save_read_data, :read_data
def read_data(file)
# The Usual
trick_time_save_read_data(file)
# Load Game Time
$game_time = Marshal.load(file)
end
end
class Game_Event
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias_method :trick_time_event_initialize, :initialize
def initialize(map_id, event, *extra)
# Setup Event
@event = event
# Setup Arguments
args = %w( Time_Setup start_minute end_minute start_hour end_hour
start_day end_day start_month end_month start_year end_year on_day
on_month night day evening morning script)
# Get Setup Information from Comments
time_setup = event_comment_list(*args)
# If not nil and has the View Range Key Set Instance Variable
@time_setup = time_setup unless time_setup == nil
# The Usual
trick_time_event_initialize(map_id, event, *extra)
end
#--------------------------------------------------------------------------
# * Time Condition
#--------------------------------------------------------------------------
def condition_time(page)
return if @event.pages.index(page) == nil
return @time_setup[@event.pages.index(page)]
end
#--------------------------------------------------------------------------
# * Refresh Trigger Conditions
#--------------------------------------------------------------------------
def refresh_trigger_conditions
# Check in order of large event pages
for page in @event.pages.reverse
# Skips If Page Conditions Not Met
next unless page.condition.conditions_met?(@map_id, @id)
next unless time_conditions_met?(page)
# Set local variable: new_page
new_page = page
# Remove loop
break
end
# Return new page
return new_page
end
#--------------------------------------------------------------------------
# * Time Conditions Met?
#--------------------------------------------------------------------------
def time_conditions_met?(page)
# Get Time Setup for Page
time_cond = condition_time(page)
# Return flag if not valid
return true if time_cond == nil or not time_cond.has_key?('Time_Setup')
# Evaluate Minute Handlers if any
min1, min2 = time_cond['start_minute'], time_cond['end_minute']
# If Passed Minute Conditions
return false unless min1 == nil or $game_time.minutes >= min1
return false unless min2 == nil or $game_time.minutes <= min2
# Evaluate Hour Handlers if any
hour1, hour2 = time_cond['start_hour'], time_cond['end_hour']
# If Passed Hour Conditions
return false unless hour1 == nil or $game_time.hours >= hour1
return false unless hour2 == nil or $game_time.hours <= hour2
# Evaluate Day Handlers if any
day1, day2 = time_cond['start_day'], time_cond['end_day']
# If Passed Day Conditions
return false unless day1 == nil or $game_time.days >= day1
return false unless day2 == nil or $game_time.days <= day2
# Evaluate Month Handlers if any
month1, month2 = time_cond['start_month'], time_cond['end_month']
# If Passed Hour Conditions
return false unless month1 == nil or $game_time.months >= month1
return false unless month2 == nil or $game_time.months <= month2
# Evaluate Year Handlers if any
year1, year2 = time_cond['start_year'], time_cond['end_year']
# If Passed Hour Conditions
return false unless year1 == nil or $game_time.years >= year1
return false unless year2 == nil or $game_time.years <= year2
# Evaluate on Day Handlers
on_day = time_cond['on_day']
# If Passed On Day Condition
return false unless on_day == nil or on_day == $game_time.current_day
# Evaluate on Month Handlers
on_month = time_cond['on_month']
# If Passed On Month Condition
return false unless on_month == nil or on_month == $game_time.current_month
# Get Time of Day Conditions
morning, afternoon = time_cond['morning'], time_cond['afternoon']
evening, night = time_cond['evening'], time_cond['night']
# If Passed Morning Condition
return false if morning != nil and morning ^ $game_time.is_morning?
# If Passed Afternoon Condition
return false if afternoon != nil and afternoon ^ $game_time.is_afternoon?
# If Passed Evening Condition
return false if evening != nil and evening ^ $game_time.is_evening?
# If Passed Night Condition
return false if night != nil and night ^ $game_time.is_night?
# Get Script Condition
script = time_cond['script']
# If Passed Script Condition
return false if script != nil and not $game_time.instance_eval(script)
# Passed Time Conditions
return true
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
Code:
=begin
==============================================================================
â—â— HUD Addon for Trickster's Time System
------------------------------------------------------------------------------
Trickster (tricksterguy@hotmail.com)
Version 1.0
Date 3/31/07
Goto rmxp.org for updates/support/bug reports
==============================================================================
=end
#--------------------------------------------------------------------------
# * Begin SDK Log
#--------------------------------------------------------------------------
SDK.log('Time HUD', 'Trickster', 1.0, '3.21.07')
#--------------------------------------------------------------------------
# Begin SDK Requirement Check
#--------------------------------------------------------------------------
SDK.check_requirements(2.2, [1, 2, 3, 4], ['Time System'])
#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.enabled?('Time HUD')
module Time_Setup
#--------------------------------------------------------------------------
# * Time HUD Location
# - note: width = 160 height = 64
#--------------------------------------------------------------------------
Position = 480, 0
#--------------------------------------------------------------------------
# * Time HUD Opacity
#--------------------------------------------------------------------------
Opacity = 160
#--------------------------------------------------------------------------
# * Time HUD Back Opacity
#--------------------------------------------------------------------------
Back_Opacity = 160
#--------------------------------------------------------------------------
# * HUD Switch
# - Switch ID to turn hud off
#--------------------------------------------------------------------------
HUD_Switch = 100
end
class Window_TimeHUD < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Call Window_Base#initialize
super(0, 0, 160, 64)
# Setup Contents
self.contents = Bitmap.new(width - 32, height - 32)
# Setup Time
@time = nil
# Setup Opacity
self.opacity = Time_Setup::Opacity
# Setup Back Opacity
self.back_opacity = Time_Setup::Back_Opacity
# Refresh
refresh
# Setup Visibility
self.visible = $game_switches[Time_Setup::HUD_Switch]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Return if same time
return if @time == $game_time.time
# Set Time
@time = $game_time.time
# Clear
self.contents.clear
# Get Width
cx = contents.text_size('Time').width
# System Color
self.contents.font.color = system_color
# Draw Time Text
self.contents.draw_text(0, 0, cx, 32, 'Time', 2)
# Normal Color
self.contents.font.color = normal_color
# Get Width
dx = contents.text_size(@time).width
# Print Time
self.contents.draw_text(cx, 0, contents.width - cx, 32, $game_time.time, 2)
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
# Call Window_Base#update
super
# Refresh if different time
refresh if @time != $game_time.time
# Setup Visibility
self.visible = $game_switches[Time_Setup::HUD_Switch]
end
end
class Scene_Map
#--------------------------------------------------------------------------
# * Main Window
#--------------------------------------------------------------------------
alias_method :trick_timehud_map_main_window, :main_window
def main_window
# The Usual
trick_timehud_map_main_window
# Create Time Hud Window
@time_hud = Window_TimeHUD.new
# Setup it's position
@time_hud.x, @time_hud.y = Time_Setup::Position
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
Not asking for much. I've been trying to figure out how to do it myself, but it'd help if I knew something about scripting ~.~ (doesn't know crap 'bout scripting ':|)
Thanks in Advance.