I need help on the day and time system.i have an inn what script should i call to add hours
here is the script:
here is the script:
Code:
#==============================================================================
# Created by Tiberius_XXVII, December 3, 2005
#------------------------------------------------------------------------------
# Instructions
#
# 1. Go to "def initialize" (Starts at line 31)
# 2. Under "Maximums/Standards" change the variables to what you want. Current is Earth time.
# Also currently has four holidays: Christmas, New Years and their eve's. Please add some! :)
# 3. Under "Starting" change the variables to what you want. Current is 12:00 a.m. January 1, 2000.
#==============================================================================
#==============================================================================
# Game Time
#------------------------------------------------------------------------------
# The day and time of the game.
#==============================================================================
class Game_Time
#--------------------------------------------------------------------------
# Attributes
#--------------------------------------------------------------------------
attr_reader :minute
attr_reader :hour
attr_reader :day
attr_reader :month
attr_reader :year
attr_reader :date
attr_reader :temperature
attr_reader :control_tint
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize
#Maximums/Standards (CHANGE THESE IF YOU WANT)
@seconds = 20 #frames in a minute
@minutes = 60 #minutes in an hour
@hours = 24 #hours in a day
@monthes = [["January", 31], ["February", 28], ["March", 31], ["April", 30], # Month names and
["May", 31], ["June", 30], ["July", 31], ["August", 31], # amount of days in
["September", 30], ["October", 31], ["November", 30], ["December", 31]] # each. You can have
# more than 12 months.
@holidays = [[1, 1, "New Year's Day"], [12, 24, "Christmas Eve"], # Month, day, and name of
[12, 25, "Christmas"], [12, 31, "New Year's Eve"]] # holidays. Add some!
@temperatures = [[-11, 9], [-4, 16], [3, 23], [10, 30], [17, 37], #The high and low temperatures
[24, 44], [17, 37], [10, 30], [3, 23], [-4, 16], [-11, 9], [-18, 2]] #for each month, uses Celcius.
#I just guessed for these.
@days = ["Sunday", "Monday", "Tuesday", "Wednsday", "Thursday", "Friday", "Saturday"] # Names
# of the days of the week.
# Use as many as you want.
#Starting (CHANGE THESE IF YOU WANT)
@second = 0
@minute = 55
@hour = 12
@day = 24
@month = 8
@year = 2007
@day_id = 0 # Sunday
#Fixes (DO NOT CHANGE)
@temp_plus = 0
@control_weather = true
@control_tint = true
@control_temp = true
@weather = 0
@date = month_name + " " + @day.to_s + " "
fix_date
x = (@hour - @hours / 2).abs
@temperature = (rand(@temperatures[@month - 1][1] - @temperatures[@month - 1][0] +
(@hours / 4) - x) + @temperatures[@month - 1][0]).to_i
x *= -10
t = @temperature
$game_screen.start_tone_change(Tone.new(x + (0.7273 * t - 24), x + (0.5818 * t - 25.6), x + (-1.02 * t + 20.8), 1.164 * t + 12.8), 0)
fix_temp
end
#--------------------------------------------------------------------------
# Step
#--------------------------------------------------------------------------
def step
need_fix = false
@second += 1
if @second >= @seconds
@second = 0
@minute += 1
end
if @minute >= @minutes
@minute = 0
@hour += 1
if rand(100) < 20
@weather = -@weather + 1
end
if @control_tint
x = -(@hour - @hours / 2).abs * 10
t = @temperature
$game_screen.start_tone_change(Tone.new(x + (0.7273 * t - 24), x + (0.5818 * t - 25.6), x + (-1.02 * t + 20.8), 1.164 * t + 12.8), 30)
end
fix_temp
end
if @hour >= @hours
@hour = 0
@day += 1
@day_id += 1
if @day_id == @days.size
@day_id = 0
end
need_fix = true
end
if @day > @monthes[@month - 1][1]
@day = 1
@month += 1
end
if @month > @monthes.size
@month = 1
@year += 1
end
if need_fix
fix_date
end
end
#--------------------------------------------------------------------------
# Month Name
#--------------------------------------------------------------------------
def month_name
return @monthes[@month - 1][0]
end
#--------------------------------------------------------------------------
# Day Name
#--------------------------------------------------------------------------
def day_name
return @days[@day_id]
end
#--------------------------------------------------------------------------
# Fix Day
#--------------------------------------------------------------------------
def fix_date
@date = month_name + " " + @day.to_s + " "
for i in 0...@holidays.size
if @holidays[i][0] == @month and @holidays[i][1] == @day
@date = @holidays[i][2] + " "
break
end
end
end
#--------------------------------------------------------------------------
# Fix Temperature
#--------------------------------------------------------------------------
def fix_temp
@temperature -= @temp_plus
y = (3 * (@temperatures[@month - 1][1] - @temperatures[@month - 1][0]) / @hours).to_i
if @hour <= (@hours / 2)
@temperature += rand(y)
end
if @hour > (@hours / 2)
@temperature -= rand(y)
end
if @temperature > @temperatures[month - 1][1]
@temperature = @temperatures[month - 1][1]
end
if @temperature < @temperatures[month - 1][0]
@temperature = @temperatures[month - 1][0]
end
@temperature = @temperature.to_i
@temperature += @temp_plus
fix_weather
end
#--------------------------------------------------------------------------
# Fix Weather
#--------------------------------------------------------------------------
def fix_weather
if @control_weather
$game_system.bgs_play(nil)
x = 0
if @weather == 1
x = 3
if @temperature > 0
x = 1
bgs = BGS.new
bgs.name = "005-Rain01"
$game_system.bgs_play(bgs)
end
end
$game_screen.weather(x, 10, 10)
end
end
#--------------------------------------------------------------------------
# Control
#--------------------------------------------------------------------------
def control(type, allow)
if type == 0
@control_temp = allow
if allow
x = (@hour - @hours / 2).abs
@temperature = (rand(@temperatures[@month - 1][1] - @temperatures[@month - 1][0] +
(@hours / 4) - x) + @temperatures[@month - 1][0]).to_i
for i in 0..@hour
fix_temp
end
end
end
if type == 1
@control_weather = allow
fix_weather
end
if type == 2
@control_tint = allow
if allow
x = -(@hour - @hours / 2).abs * 10
t = @temperature
$game_screen.start_tone_change(Tone.new(x + (0.7273 * t - 24), x + (0.5818 * t - 25.6), x + (-1.02 * t + 20.8), 1.164 * t + 12.8), 0)
end
fix_weather
end
end
#--------------------------------------------------------------------------
# Set Temperature
#--------------------------------------------------------------------------
def set_temp(min, max)
@temperature = rand(max - min) + min
end
#--------------------------------------------------------------------------
# Set Temperature Change
#--------------------------------------------------------------------------
def set_temp_change(change)
@temperature -= @temp_plus
@temp_plus = change
@temperature += change
end
end
#==============================================================================
# Window_Time
#------------------------------------------------------------------------------
# Displays the date and time
#==============================================================================
class Window_Time < Window_Base
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize
super(0, 0, 224, 104)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
self.back_opacity = 128
update
end
#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
def update
self.contents.clear
minute = $game_time.minute.to_s
if $game_time.minute < 10
minute = "0" + $game_time.minute.to_s
end
time = " a.m. "
if $game_time.hour > 11
time = " p.m. "
end
hour = $game_time.hour
if hour == 0
hour = 12
end
if hour > 12
hour -= 12
end
self.contents.draw_text(4, 0, 192, 32, hour.to_s + ":" + minute + time)
self.contents.draw_text(4, 24, 192, 32, "Temperature: " + $game_time.temperature.to_s + "? C")
self.contents.draw_text(4, 48, 192, 32, $game_time.day_name + ", " + $game_time.date + ", " + $game_time.year.to_s)
end
end
#==============================================================================
# BGS
#------------------------------------------------------------------------------
# The background sound thing
#==============================================================================
class BGS
#--------------------------------------------------------------------------
# Attributes
#--------------------------------------------------------------------------
attr_accessor :name
attr_accessor :volume
attr_accessor :pitch
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize
@name = ""
@volume = 80
@pitch = 100
end
end