Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # ***Time and Period System***
- #
- # Author: eugene222 (Evgenij)
- # Version: 1.2a
- # Date: 18.05.2014
- # Requires: ---
- #===============================================================================
- # Changelog:
- #
- # 03.04.2014 - V. 1.0-alpha1 - script created
- # 05.04.2014 - V. 1.0 - fixed some bugs, added new Script Calls
- # 06.04.2014 - V. 1.0a - Game_Time now updates in Scene_*.update_basic
- # 09.04.2014 - V. 1.1 - refactored the code
- # 18.05.2014 - V. 1.2 - Days, Months and Years added
- # 21.08.2014 - V. 1.2a - fixed a bug
- #
- #===============================================================================
- # Terms of Use:
- # You can use this script for free and commercial projects as long as you give
- # credits.
- #===============================================================================
- # Description:
- # This script adds a time system to your game.
- #
- # It doesnt add, windows, tints or other features. For other features use the
- # addons.
- #
- # Released Addons:
- # - Tints for Periods
- # - Period PopUp
- # - Clock Window
- # - Phases and Weather
- #
- # Planed:
- #
- # - Khas Awesome Light Support
- #
- #
- #===============================================================================
- # ScriptCalls:
- #
- # Since V. 1.2:
- #
- #-------------------------------------------------------------------------------
- #
- # IMPORTANT: the calls jump_to_date, set_day, set_month and set year dont change
- # the weekday. If its thursday the 3rd and you change the day to
- # the 10th it stays thursday.
- # I will try to fix it in the future.
- #
- #-------------------------------------------------------------------------------
- # $game_time.current_day # Current Day (as number)
- #
- #-------------------------------------------------------------------------------
- # $game_time.current_day_vocab # Current Day Vocab
- #
- #-------------------------------------------------------------------------------
- # $game_time.current_week_day # Weekday as number
- #
- #-------------------------------------------------------------------------------
- # # Short Vocab of current day:
- # $game_time.current_day_vocab_short
- #
- #-------------------------------------------------------------------------------
- # $game_time.current_month # Current month as number
- #
- #-------------------------------------------------------------------------------
- # $game_time.current_month_vocab # Current month vocab
- #
- #-------------------------------------------------------------------------------
- # # Short vocab of current month:
- # $game_time.current_month_vocab_short
- #
- #-------------------------------------------------------------------------------
- #
- # # Set the date: (period ist optional)
- # $game_time.jump_to_date(year, month, day [, period])
- #
- #-------------------------------------------------------------------------------
- # $game_time.set_day(day) # Set day in current month
- #
- #-------------------------------------------------------------------------------
- # $game_time.set_month(month) # Set month in current year
- #
- #-------------------------------------------------------------------------------
- # $game_time.set_year(year) # Set year
- #
- #-------------------------------------------------------------------------------
- # $game_time.add_day(a) # increase days
- #
- #-------------------------------------------------------------------------------
- # $game_time.reduce_day(a) # decrease days
- #
- #-------------------------------------------------------------------------------
- # $game_time.add_month(a) # increase month
- #
- #-------------------------------------------------------------------------------
- # $game_time.reduce_month(a) # decrease month
- #
- #-------------------------------------------------------------------------------
- # $game_time.add_year(a) # increase years
- #
- #-------------------------------------------------------------------------------
- # $game_time.reduce_year(a) # decrease years
- #
- #-------------------------------------------------------------------------------
- #
- # ---------- Old Scriptcalls: ----------
- #
- # $game_time.period_text # return current period vocab
- # $game_time.hour # return current hour
- # $game_time.minute # return current minute
- #
- # $game_time.stop_time # stop timeflow
- # $game_time.resume_time # resume timeflow with default speed
- #
- # $game_time.jump_to(:p) # time jumps to period :p
- # $game_time.set_time(t) # change time to (0 - 1439)
- # &game_time.add_time(n) # increase minutes
- # $game_time.reduce_time(n) # decrease minutes
- #
- # &game_time.set_speed(s) # set time speed to s. If s is high, the speed is low
- #
- # $game_time.full_speed # set time speed to fastest
- # $game_time.double_speed # double time speed
- # $game_time.half_speed # half time speed
- # $game_time.default_speed # set time speed to default
- #
- #--------------------------------------------------------------------------------
- #
- # You can set indoor maps
- # You need to write <indoor> at your indoor maps notetags.
- #
- # Returns true if current map is indoor:
- #
- # $game_map.indoor?
- #
- #--------------------------------------------------------------------------------
- #
- # Return true if one of the arguments is the current period
- #
- # $game_time.period_is?(:period1, :period2, ... )
- #
- #--------------------------------------------------------------------------------
- #
- # Returns true if one of the arguments is NOT the current period
- #
- # $game_time.period_is_not?(:period1, period2, ... )
- #
- #--------------------------------------------------------------------------------
- #
- # Return true if the current time is between start_time and end_time
- #
- # $game_time.time_now_between?(start_time, end_time)
- #
- #--------------------------------------------------------------------------------
- #
- # Return true if the current time is NOT between start_time and end_time
- #
- # $game_time.time_now_not_between?(start_time, end_time)
- #
- #===============================================================================
- module TPS_CONFIG
- #-----------------------------------------------------------------------------
- # DEFAULT SPEED (60 Frames = 1 Second)
- #-----------------------------------------------------------------------------
- FRAME_COUNT = 60
- #-----------------------------------------------------------------------------
- # DEFAULT START TIME (0 - 1439)
- #-----------------------------------------------------------------------------
- START_TIME = 360 # New Game starts at 6 O'Clock
- #-----------------------------------------------------------------------------
- # Start Year
- #-----------------------------------------------------------------------------
- START_YEAR = 1
- #-----------------------------------------------------------------------------
- # HOW MANY DAYS SHOULD A MONTH HAVE?
- #-----------------------------------------------------------------------------
- DAYS_IN_MONTH = 31
- #-----------------------------------------------------------------------------
- # SHOULD THE TIME UPDATE IN BATTLE?
- #-----------------------------------------------------------------------------
- UPDATE_IN_BATTLE = true
- #-----------------------------------------------------------------------------
- # SHOULD THE TIME UPDATE IN MENU
- # - I highly recommend false
- #-----------------------------------------------------------------------------
- UPDATE_IN_MENU = false
- #-----------------------------------------------------------------------------
- # SHOULD THE TIME UPDATE IN INDOOR MAPS?
- #-----------------------------------------------------------------------------
- UPDATE_INDOOR = true
- #-----------------------------------------------------------------------------
- # SHOULD THE TIME UPDATE DURING MESSAGE WINDOWS?
- # - I highly recommend keeping this false
- #-----------------------------------------------------------------------------
- UPDATE_DURING_MESSAGE = false
- #-----------------------------------------------------------------------------
- # SAVES CURRENT TIME IN THE VARIABLE WITH THIS ID
- # Set to false if you dont want to use this
- #-----------------------------------------------------------------------------
- TIME_VARIABlE_ID = 12 # number or false
- #-----------------------------------------------------------------------------
- # SAVES CURRENT DAY IN THIS VARIABLE
- #-----------------------------------------------------------------------------
- DAY_VARIABLE_ID = false
- #-----------------------------------------------------------------------------
- # SAVES CURRENT MONTH IN THIS VARIABLE
- #-----------------------------------------------------------------------------
- MONTH_VARIABLE_ID = false
- #-----------------------------------------------------------------------------
- # SAVES CURRENT YEAR IN THIS VARIABLE
- #-----------------------------------------------------------------------------
- YEAR_VARIABLE_ID = false
- #-----------------------------------------------------------------------------
- PERIOD_TIMES = { # Diese Zeile nicht verändern
- #-----------------------------------------------------------------------------
- # START TIMES FOR THE PERIODS
- #
- # KEEP THE ORDER FROM LOWEST TIME TO HIGHEST TIME
- # YOU CAN ADD AS MANY PERIODS AS YOU WISH, YOU JUST NEED TO ADD THEM TO ALL
- # ADDONS, AND VOCAB HASHES
- #
- # PERIODS STARTS WITH DOUBlEPOINTS: :period
- #-----------------------------------------------------------------------------
- # !!!!KEEP THE ORDER FROM LOWEST TIME TO HIGHEST TIME!!!!
- #-----------------------------------------------------------------------------
- #---------------------------------------------------------------------------
- # 0 = 0 AM, 360 = 6 AM, 720 = 0 PM etc.
- #---------------------------------------------------------------------------
- :morning => 360, # ab 6 Uhr (360)
- :forenoon => 600, # ab 10 Uhr (600)
- :noon => 720, # ab 12 Uhr (720)
- :afternoon => 780, # ab 13 Uhr (780)
- :evening => 1020, # ab 17 Uhr (1020)
- :night => 1320, # ab 22 Uhr (1320)
- #-----------------------------------------------------------------------------
- }# Diese Zeile nicht verändern!
- #-----------------------------------------------------------------------------
- # DO YOU WANT TO USE SWITCHES FOR THE PERIODS?
- #-----------------------------------------------------------------------------
- USE_SWITCHES = true
- #-----------------------------------------------------------------------------
- # DEFINE SWITCH IDS FOR THE PERIODS
- #-----------------------------------------------------------------------------
- PERIOD_SWITCH_IDs = { # Diese Zeile nicht verändern!
- #-----------------------------------------------------------------------------
- :morning => 1,
- :forenoon => 2,
- :noon => 3,
- :afternoon => 4,
- :evening => 5,
- :night => 6
- #-----------------------------------------------------------------------------
- }# Diese Zeile nicht verändern!
- #-----------------------------------------------------------------------------
- # VOCAB FOR THE PERIODS
- #-----------------------------------------------------------------------------
- PERIOD_VOCABS = {
- :morning => "Morning",
- :forenoon => "Forenoon",
- :noon => "Noon",
- :afternoon => "Afternoon",
- :evening => "Evening",
- :night => "Night",
- #-----------------------------------------------------------------------------
- }# Diese Zeile nicht verändern!
- #-----------------------------------------------------------------------------
- # HERE YOU NEED TO DEFINE THE MONTH. THE SIZE DOESNT MATTER.
- #
- # OTHER EXAMPLE (LIKE Harvest Moon):
- # MONTHS = ["Frühling", "Sommer", "Herbst", "Winter"]
- #-----------------------------------------------------------------------------
- MONTHS = ["January", "February", "March", "April", "May", "June", "July",
- "August", "September", "October", "November", "December"]
- MONTHS_SHORT = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
- "Sep", "Oct", "Nov", "Dec"]
- #-----------------------------------------------------------------------------
- # HERE YOU NEED TO DEFINE THE WEEKDAYS
- #-----------------------------------------------------------------------------
- DAYS = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
- "Saturday", "Sunday" ]
- DAYS_SHORT = ["Mo.", "Tu.", "We.", "Th.", "Fr.", "Sa.", "Su."]
- #-----------------------------------------------------------------------------
- # CONFIG END
- #-----------------------------------------------------------------------------
- #-----------------------------------------------------------------------------
- # IGNORE THIS
- #
- # Fürs Debugging:
- # Optionen:
- # false - no Debugging
- # :day -
- # :month -
- # :year -
- #-----------------------------------------------------------------------------
- DEBUG_TICKS = false
- #-----------------------------------------------------------------------------
- end
- #===============================================================================
- # END OF CONFIG
- #===============================================================================
- $imported ||= {}
- $imported[:e222_tps_core] = 1.2
- #===============================================================================
- # Data_Manager
- #===============================================================================
- module DataManager
- #--------------------------------------------------------------------------
- # alias
- #--------------------------------------------------------------------------
- class << self
- alias game_time_cgo create_game_objects
- alias game_time_msc make_save_contents
- alias game_time_esc extract_save_contents
- end
- #--------------------------------------------------------------------------
- # * Create Game Objects
- #--------------------------------------------------------------------------
- def self.create_game_objects
- game_time_cgo
- $game_time = Game_Time.new
- end
- #--------------------------------------------------------------------------
- # * Create Save Contents
- #--------------------------------------------------------------------------
- def self.make_save_contents
- contents = game_time_msc
- contents[:time] = $game_time
- contents
- end
- #--------------------------------------------------------------------------
- # * Extract Save Contents
- #--------------------------------------------------------------------------
- def self.extract_save_contents(contents)
- game_time_esc(contents)
- $game_time = contents[:time] if contents[:time]
- $game_time.reinitialize
- end
- #--------------------------------------------------------------------------
- end
- #===============================================================================
- # New Class Game_Time, handles the time processing
- #===============================================================================
- class Game_Time
- #-----------------------------------------------------------------------------
- include TPS_CONFIG
- #-----------------------------------------------------------------------------
- attr_reader :current_time
- attr_reader :current_period
- attr_reader :current_day
- attr_reader :current_month
- attr_reader :current_year
- attr_reader :time_progress
- attr_accessor :time_progress_for_transfer
- #-----------------------------------------------------------------------------
- # initialize all values
- #-----------------------------------------------------------------------------
- def initialize
- reinitialize
- end
- #-----------------------------------------------------------------------------
- # Reinitialize
- #-----------------------------------------------------------------------------
- def reinitialize
- @time_progress = true if @time_progress.nil?
- @time_progress_for_transfer = true if @time_progress_for_transfer.nil?
- @current_time ||= start_time
- @time_speed ||= time_speed
- @current_day ||= 0
- @week_day ||= 0
- @current_month ||= 0
- @current_year ||= START_YEAR
- @year_counter ||= 1
- make_cache
- end
- #-----------------------------------------------------------------------------
- # Make Cache
- #-----------------------------------------------------------------------------
- def make_cache
- setup_period_hash
- end
- #-----------------------------------------------------------------------------
- # Start Time
- #-----------------------------------------------------------------------------
- def start_time
- return 0 unless (0..1439).include?(START_TIME)
- START_TIME
- end
- #-----------------------------------------------------------------------------
- # Time Speed
- #-----------------------------------------------------------------------------
- def time_speed
- return FRAME_COUNT
- end
- #-----------------------------------------------------------------------------
- # Setup Period Hash
- # 1. Hole die Keys aus PERIOD_TIMES (.keys)
- # 2. Kopiere den letzten Key an die erste Stelle im Array (.unshift)
- # 3. Mache ein Enumerator aus den Zeiten (.each_cons(2))
- # 3.1. Füge den Enumerator mit dem Key Array zusammen (.zip)
- # Bsp: [:night, [0, 360]]
- # 4. Iteriere durch das Array und mache ein Hash daraus (.each_with_object)
- #
- # Der Hash sieht am Ende so aus:
- # [0 => :night, 1 => :night, ..., 378 => :morning, ...]
- #
- # Das ganze ermöglicht einen schnellen Zugriff auf die momentane Periode
- # abhängig von der Zeit.
- #-----------------------------------------------------------------------------
- def setup_period_hash
- @period_hash = PERIOD_TIMES.
- keys.
- unshift(PERIOD_TIMES.keys.last).
- zip([0, * PERIOD_TIMES.values, 1440,].each_cons(2)).
- each_with_object({}) do |(period, (from, to)), hash|
- (from..to).each do |time|
- hash[time] = period
- end
- end
- end
- #-----------------------------------------------------------------------------
- # Update Method
- #-----------------------------------------------------------------------------
- def update
- return unless need_update?
- if (Graphics.frame_count % @time_speed).zero?
- case DEBUG_TICKS
- when false
- next_minute
- when :day
- next_day
- when :month
- next_month
- when :year
- next_year
- end
- update_period
- end
- end
- #-----------------------------------------------------------------------------
- # Initialize Period
- #-----------------------------------------------------------------------------
- def initialize_period
- @current_period = return_period(@current_time)
- refresh_period_switches
- end
- #-----------------------------------------------------------------------------
- # Update Period
- #-----------------------------------------------------------------------------
- def update_period
- return unless period_need_update?
- @current_period = return_period(@current_time)
- refresh_period
- end
- #-----------------------------------------------------------------------------
- # Refresh Period
- #-----------------------------------------------------------------------------
- def refresh_period
- refresh_period_switches
- end
- #-----------------------------------------------------------------------------
- # Next Minute
- #-----------------------------------------------------------------------------
- def next_minute
- @current_time += 1
- next_day if @current_time > 1439
- refresh_time_variable
- end
- #-----------------------------------------------------------------------------
- # Next Day
- #-----------------------------------------------------------------------------
- def next_day
- @current_time = 0
- @current_day += 1
- @week_day = (@week_day + 1) % days_in_week
- next_month if @current_day >= days_in_month#
- update_day_variable
- end
- #-----------------------------------------------------------------------------
- # Next Month
- #-----------------------------------------------------------------------------
- def next_month
- @current_day = 0
- @current_month += 1
- next_year if @current_month >= months_in_year
- update_month_variable
- end
- #-----------------------------------------------------------------------------
- # Next Year
- #-----------------------------------------------------------------------------
- def next_year
- @current_month = 0
- @current_year += 1
- @year_counter += 1
- update_year_variable
- end
- #-----------------------------------------------------------------------------
- # Refresh Time Variable
- #-----------------------------------------------------------------------------
- def refresh_time_variable
- return unless TIME_VARIABlE_ID
- $game_variables[TIME_VARIABlE_ID] = @current_time
- end
- #-----------------------------------------------------------------------------
- # Refresh Period Switches
- #-----------------------------------------------------------------------------
- def refresh_period_switches
- return unless USE_SWITCHES
- PERIOD_SWITCH_IDs.each_value { |id| $game_switches[id] = false }
- $game_switches[PERIOD_SWITCH_IDs[@current_period]] = true
- end
- #-----------------------------------------------------------------------------
- # Return Period
- #-----------------------------------------------------------------------------
- def return_period(time)
- @period_hash[time]
- end
- #-----------------------------------------------------------------------------
- # Days in Week
- #-----------------------------------------------------------------------------
- def days_in_week
- DAYS.size
- end
- #-----------------------------------------------------------------------------
- # Days in Month
- #-----------------------------------------------------------------------------
- def days_in_month
- return days_in_week if DAYS_IN_MONTH < days_in_week
- DAYS_IN_MONTH
- end
- #-----------------------------------------------------------------------------
- # Months in Year
- #-----------------------------------------------------------------------------
- def months_in_year
- MONTHS.size
- end
- #-----------------------------------------------------------------------------
- # Update Day Variable
- #-----------------------------------------------------------------------------
- def update_day_variable
- return unless DAY_VARIABLE_ID
- $game_variables[DAY_VARIABLE_ID] = current_day
- end
- #-----------------------------------------------------------------------------
- # Update Month Variable
- #-----------------------------------------------------------------------------
- def update_month_variable
- return unless MONTH_VARIABLE_ID
- $game_variables[MONTH_VARIABLE_ID] = current_month
- end
- #-----------------------------------------------------------------------------
- # Update Year Variable
- #-----------------------------------------------------------------------------
- def update_year_variable
- return unless YEAR_VARIABLE_ID
- $game_variables[MONTH_VARIABLE_ID] = @current_year
- end
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # Boolean Methods:
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #-----------------------------------------------------------------------------
- # Time Need Update?
- #-----------------------------------------------------------------------------
- def need_update?
- return false unless @time_progress
- return false unless @time_progress_for_transfer
- return false if $game_message.visible && !UPDATE_DURING_MESSAGE
- return false if $game_map.indoor? && !UPDATE_INDOOR
- return true
- end
- #-----------------------------------------------------------------------------
- # Period Need Update?
- #-----------------------------------------------------------------------------
- def period_need_update?
- @current_period != return_period(@current_time)
- end
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # Period and Time Changing Script Calls:
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #-----------------------------------------------------------------------------
- # Jump to Period
- #-----------------------------------------------------------------------------
- def jump_to(period)
- set_time(PERIOD_TIMES[period])
- end
- #-----------------------------------------------------------------------------
- # Jump to Date
- #-----------------------------------------------------------------------------
- def jump_to_date(year, month = 0, day = 0, period = nil)
- set_year(year)
- set_month(month)
- set_day(day)
- jump_to(period || return_period(0))
- end
- #-----------------------------------------------------------------------------
- # Set Time
- #-----------------------------------------------------------------------------
- def set_time(time)
- return unless (0..1439).include?(time)
- @current_time = time
- refresh_time_variable
- update_period
- end
- #-----------------------------------------------------------------------------
- # Set Day
- #-----------------------------------------------------------------------------
- def set_day(day)
- return unless (0..days_in_month).include?(day - 1)
- @current_day = day - 1
- update_day_variable
- end
- #-----------------------------------------------------------------------------
- # Set Month
- #-----------------------------------------------------------------------------
- def set_month(month)
- return unless (0..months_in_year).include?(month - 1)
- @current_month = month - 1
- update_month_variable
- end
- #-----------------------------------------------------------------------------
- # Set Year
- #-----------------------------------------------------------------------------
- def set_year(year)
- @current_year = year
- update_year_variable
- end
- #-----------------------------------------------------------------------------
- # Add Time
- #-----------------------------------------------------------------------------
- def add_time(amount)
- change_time(amount.abs)
- end
- #-----------------------------------------------------------------------------
- # Reduce Time
- #-----------------------------------------------------------------------------
- def reduce_time(amount)
- change_time(amount.abs * (-1))
- end
- #-----------------------------------------------------------------------------
- # Add Day
- #-----------------------------------------------------------------------------
- def add_day(amount)
- change_day(amount.abs)
- end
- #-----------------------------------------------------------------------------
- # Reduce Day
- #-----------------------------------------------------------------------------
- def reduce_day(amount)
- change_day(amount.abs * (-1))
- end
- #-----------------------------------------------------------------------------
- # Add Month
- #-----------------------------------------------------------------------------
- def add_month(amount)
- change_month(amount.abs)
- end
- #-----------------------------------------------------------------------------
- # Reduce Month
- #-----------------------------------------------------------------------------
- def reduce_month(amount)
- change_month(amount.abs * (-1))
- end
- #-----------------------------------------------------------------------------
- # Add Year
- #-----------------------------------------------------------------------------
- def add_year(amount)
- change_year(amount.abs)
- end
- #-----------------------------------------------------------------------------
- # Reduce Year
- #-----------------------------------------------------------------------------
- def reduce_year(amount)
- change_year(amount.abs * (-1))
- end
- #-----------------------------------------------------------------------------
- # Change Time
- #-----------------------------------------------------------------------------
- def change_time(amount)
- change_day((@current_time + amount) / 1440)
- @current_time = (@current_time + amount) % 1440
- refresh_time_variable
- end
- #-----------------------------------------------------------------------------
- # Change Day
- #-----------------------------------------------------------------------------
- def change_day(amount)
- change_month((@current_day + amount) / days_in_month)
- @current_day = (@current_day + amount) % days_in_month
- @week_day = (@week_day + amount) % days_in_week
- update_day_variable
- end
- #-----------------------------------------------------------------------------
- # Change Month
- #-----------------------------------------------------------------------------
- def change_month(amount)
- change_year((@current_month + amount) / months_in_year)
- @current_month = (@current_month + amount) % months_in_year
- update_month_variable
- end
- #-----------------------------------------------------------------------------
- # Change Year
- #-----------------------------------------------------------------------------
- def change_year(amount)
- @current_year = [(@current_year + amount), 0].max
- update_period
- update_year_variable
- end
- #-----------------------------------------------------------------------------
- # Stop Time
- #-----------------------------------------------------------------------------
- def stop_time
- @time_progress = false
- end
- #-----------------------------------------------------------------------------
- # Resume Time
- #-----------------------------------------------------------------------------
- def resume_time
- @time_progress = true
- @time_progress_for_transfer = true
- end
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # Speed Changing Script Calls:
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #-----------------------------------------------------------------------------
- # Full Speed
- #-----------------------------------------------------------------------------
- def full_speed
- @time_speed = 1
- end
- #-----------------------------------------------------------------------------
- # Double Speed
- #-----------------------------------------------------------------------------
- def double_speed
- @time_speed /= 2
- @time_speed = 1 if @time_speed < 1
- end
- #-----------------------------------------------------------------------------
- # Half Speed
- #-----------------------------------------------------------------------------
- def half_speed
- @time_speed *= 2
- end
- #-----------------------------------------------------------------------------
- # Default Speed
- #-----------------------------------------------------------------------------
- def default_speed
- @time_speed = time_speed
- resume_time
- end
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # Boolean Returning Script Calls:
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #-----------------------------------------------------------------------------
- # Current Period Is One Of Periods?
- #-----------------------------------------------------------------------------
- def period_is?(*periods)
- periods.any? { |period| @current_period == period }
- end
- #-----------------------------------------------------------------------------
- # Current Period Is None Of Periods?
- #-----------------------------------------------------------------------------
- def period_is_not?(*periods)
- !period_is?(*periods)
- end
- #-----------------------------------------------------------------------------
- # Time-Now between Start Time and End Time?
- #-----------------------------------------------------------------------------
- def time_now_between?(start_time, end_time)
- (start_time..end_time).include?(@current_time)
- end
- #-----------------------------------------------------------------------------
- # Time-Now not between Start Time and End Time?
- #-----------------------------------------------------------------------------
- def time_now_not_between?(start_time, end_time)
- !time_now_between?(start_time, end_time)
- end
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # Text or Value Returning Script Calls:
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #-----------------------------------------------------------------------------
- # Current Day
- #-----------------------------------------------------------------------------
- def current_day
- return @current_day + 1
- end
- #-----------------------------------------------------------------------------
- # Current Month
- #-----------------------------------------------------------------------------
- def current_month
- return @current_month + 1
- end
- #-----------------------------------------------------------------------------
- # Current Year
- #-----------------------------------------------------------------------------
- def current_year
- return @current_year
- end
- #-----------------------------------------------------------------------------
- # Current Month Vocab Short
- #-----------------------------------------------------------------------------
- def current_month_vocab
- return MONTHS[@current_month]
- end
- #-----------------------------------------------------------------------------
- # Current Month Vocab Short
- #-----------------------------------------------------------------------------
- def current_month_vocab_short
- return MONTHS[@current_month]
- end
- #-----------------------------------------------------------------------------
- # Current Day Vocab
- #-----------------------------------------------------------------------------
- def current_day_vocab
- return DAYS[@week_day]
- end
- #-----------------------------------------------------------------------------
- # Current Day Vocab Short
- #-----------------------------------------------------------------------------
- def current_day_vocab_short
- return DAYS_SHORT[@week_day]
- end
- #-----------------------------------------------------------------------------
- # Period Name
- #-----------------------------------------------------------------------------
- def period_text
- return PERIOD_VOCABS[@current_period]
- end
- #-----------------------------------------------------------------------------
- # Hour
- #-----------------------------------------------------------------------------
- def hour
- @current_time / 60
- end
- #-----------------------------------------------------------------------------
- # Minute
- #-----------------------------------------------------------------------------
- def minute
- @current_time % 60
- end
- #-----------------------------------------------------------------------------
- # Current Weather
- #-----------------------------------------------------------------------------
- def current_weather
- screen_weather
- end
- #-----------------------------------------------------------------------------
- # Screen Weather
- #-----------------------------------------------------------------------------
- def screen_weather
- $game_map.screen.weather_type
- end
- #-----------------------------------------------------------------------------
- end # //Game_Time
- #===============================================================================
- # Game_Map
- # new_methods: indoor?
- #===============================================================================
- class Game_Map
- #-----------------------------------------------------------------------------
- # return if the current map notetag include <indoor>
- #-----------------------------------------------------------------------------
- def indoor?
- return false if $BTEST
- return false unless @map
- @map.note.include?("<indoor>")
- end
- #-----------------------------------------------------------------------------
- end
- #===============================================================================
- # Scene_Base
- # aliased_methods: update
- #===============================================================================
- class Scene_Base
- #-----------------------------------------------------------------------------
- # Update Basic
- #-----------------------------------------------------------------------------
- alias :scene_base_update_basic_e222 :update_basic
- #-----------------------------------------------------------------------------
- def update_basic
- scene_base_update_basic_e222
- update_gametime
- end
- #-----------------------------------------------------------------------------
- # Update Game Time
- #-----------------------------------------------------------------------------
- def update_gametime
- return
- end
- #-----------------------------------------------------------------------------
- end
- #===============================================================================
- # Scene_Map
- # aliased_methods: start, pre_transfer, post_transfer
- #===============================================================================
- class Scene_Map
- #-----------------------------------------------------------------------------
- # Start
- #-----------------------------------------------------------------------------
- alias :scene_map_start_e222 :start
- #-----------------------------------------------------------------------------
- def start
- scene_map_start_e222
- $game_time.initialize_period
- end
- #--------------------------------------------------------------------------
- # * Preprocessing for Transferring Player
- #--------------------------------------------------------------------------
- alias :scene_map_pre_transfer_e222 :pre_transfer
- def pre_transfer
- scene_map_pre_transfer_e222
- $game_time.time_progress_for_transfer = false
- end
- #-----------------------------------------------------------------------------
- # Post Transfer
- #-----------------------------------------------------------------------------
- alias :scene_map_post_transfer_e222 :post_transfer
- #-----------------------------------------------------------------------------
- def post_transfer
- $game_time.initialize_period
- scene_map_post_transfer_e222
- $game_time.time_progress_for_transfer = true if $game_time.time_progress
- end
- #-----------------------------------------------------------------------------
- # Update Game Time
- #-----------------------------------------------------------------------------
- def update_gametime
- $game_time.update
- end
- end
- #===============================================================================
- # Scene_MenuBase
- #===============================================================================
- class Scene_MenuBase
- #-----------------------------------------------------------------------------
- # Update Game Time
- #-----------------------------------------------------------------------------
- def update_gametime
- $game_time.update if TPS_CONFIG::UPDATE_IN_MENU
- end
- end
- #===============================================================================
- # Scene_Battle
- # aliased_methods: start
- #===============================================================================
- class Scene_Battle
- #-----------------------------------------------------------------------------
- # Start
- #-----------------------------------------------------------------------------
- alias :scene_battle_start_e222 :start
- #-----------------------------------------------------------------------------
- def start
- scene_battle_start_e222
- $game_time.initialize_period if $BTEST
- end
- #-----------------------------------------------------------------------------
- # Update Game Time
- #-----------------------------------------------------------------------------
- def update_gametime
- $game_time.update if TPS_CONFIG::UPDATE_IN_BATTLE
- end
- #------------------------------------------------------------------------------
- end
- #===============================================================================
- # SCRIPT END
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement