Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if true # << Make true to use this script, false to disable.
- #===============================================================================
- #
- # ☆ $D13x - Game Time
- # -- Author : Dekita
- # -- Version : 1.0
- # -- Level : Easy / Normal
- # -- Requires : N/A
- # -- Engine : RPG Maker VX Ace.
- #
- #===============================================================================
- # ☆ Import
- #-------------------------------------------------------------------------------
- $D13x={}if$D13x==nil
- $D13x[:Game_Time]=true
- #===============================================================================
- # ☆ Updates
- #-------------------------------------------------------------------------------
- # D /M /Y
- # 2o/o4/2o14 - Finished,
- # 11/o4/2o14 - Started
- #
- #===============================================================================
- # ☆ Introduction
- #-------------------------------------------------------------------------------
- # A simple script to recreate a 'game time' feature. Time will advance during
- # your selected scenes. You can then use script calls to check conditions
- # for using within your events.
- #
- # Also creates a simple 'time window' within the menu scene.
- #
- #===============================================================================
- # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
- #===============================================================================
- # 1. You MUST give credit to "Dekita" !!
- # 2. You are NOT allowed to repost this script.(or modified versions)
- # 3. You are NOT allowed to convert this script.
- # 4. You are NOT allowed to use this script for Commercial games.
- # 5. ENJOY!
- #
- # "FINE PRINT"
- # By using this script you hereby agree to the above terms and conditions,
- # if any violation of the above terms occurs "legal action" may be taken.
- # Not understanding the above terms and conditions does NOT mean that
- # they do not apply to you.
- # If you wish to discuss the terms and conditions in further detail you can
- # contact me at http://dekitarpg.wordpress.com/
- #
- #===============================================================================
- # ☆ Instructions
- #-------------------------------------------------------------------------------
- # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
- #
- #===============================================================================
- # ☆ Script Calls
- #-------------------------------------------------------------------------------
- # Game_Time.sec
- # Game_Time.min
- # Game_Time.hour
- # Game_Time.day
- # Game_Time.mday
- # Game_Time.month
- # Game_Time.year
- # Game_Time.set_to(sec,min,hour,day,mday,week,month,year)
- #
- #===============================================================================
- # ☆ Notetags ( default )
- #-------------------------------------------------------------------------------
- # N/A
- #
- #===============================================================================
- # ☆ HELP
- #-------------------------------------------------------------------------------
- # N/A
- #
- #===============================================================================
- module TIME
- #===============================================================================
- #-----------------------------------------------------------------------------
- # Scenes That Game_Time will update
- #-----------------------------------------------------------------------------
- UDSC = ['Scene_Map','Scene_Battle']
- #-----------------------------------------------------------------------------
- # How many frames for 1 second.
- #-----------------------------------------------------------------------------
- SEC = 2
- #-----------------------------------------------------------------------------
- # How many secs for 1 minute.
- #-----------------------------------------------------------------------------
- MIN = 60
- #-----------------------------------------------------------------------------
- # How many mins for 1 hour.
- #-----------------------------------------------------------------------------
- HOUR = 60
- #-----------------------------------------------------------------------------
- # How many hours for 1 day.
- #-----------------------------------------------------------------------------
- DAY = 24
- #-----------------------------------------------------------------------------
- # id => ['Day Name', hours in day]
- #-----------------------------------------------------------------------------
- DAYS = {
- 1 => ['Monday' , 24],
- 2 => ['Tuesday' , 24],
- 3 => ['Wednesday' , 24],
- 4 => ['Thursday' , 24],
- 5 => ['Friday' , 24],
- 6 => ['Saturday' , 24],
- 7 => ['Sunday' , 24],
- }
- #-----------------------------------------------------------------------------
- # id => ['Month Name', days in month]
- #-----------------------------------------------------------------------------
- MONT = {
- 1 => ['January' , 31],
- 2 => ['Febuary' , 31],
- 3 => ['March' , 31],
- 4 => ['April' , 31],
- 5 => ['May' , 31],
- 6 => ['June' , 31],
- 7 => ['July' , 31],
- 8 => ['August' , 31],
- 9 => ['September' , 31],
- 10 => ['October' , 31],
- 11 => ['November' , 31],
- 12 => ['December' , 31],
- }
- #####################
- # CUSTOMISATION END #
- end #####################
- #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
- # #
- # http://dekitarpg.wordpress.com/ #
- # #
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
- #===============================================================================#
- # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
- # YES?\.\. #
- # OMG, REALLY? \| #
- # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
- # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
- #===============================================================================#
- class Game_System
- #===============================================================================
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- attr_accessor :game_time_data
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- alias :game_time_data_init :initialize
- alias :game_time_on_before_save :on_before_save
- alias :game_time_on_after_load :on_after_load
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def initialize
- game_time_data_init
- Game_Time.setup
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def on_before_save
- game_time_on_before_save
- @game_time_data = Game_Time.data
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def on_after_load
- game_time_on_after_load
- load_game_time
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def load_game_time
- d = @game_time_data
- Game_Time.set_to(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7])
- end
- end
- #===============================================================================
- module Game_Time
- #===============================================================================
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.setup
- @sec = 0
- @min = 0
- @hour = 0
- @day = 1
- @mday = 1
- @week = 1
- @month = 1
- @year = 0
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.sec ; @sec ; end
- def self.sec=(sec) ; @sec = sec ; end
- def self.min ; @min ; end
- def self.min=(min) ; @min = min ; end
- def self.hour ; @hour ; end
- def self.hour=(hour) ; @hour = hour ; end
- def self.day ; @day ; end
- def self.day=(day) ; @day = day ; end
- def self.mday ; @mday ; end
- def self.mday=(mday) ; @mday = mday ; end
- def self.week ; @week ; end
- def self.week=(week) ; @week = week ; end
- def self.month ; @month ; end
- def self.month=(month) ; @month = month ; end
- def self.year ; @year ; end
- def self.year=(year) ; @year = year ; end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.data
- [@sec,@min,@hour,@day,@mday,@week,@month,@year]
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.set_to(sec,min,hour,day,mday,week,month,year)
- @sec = sec
- @min = min
- @hour = hour
- @day = day
- @mday = mday
- @week = week
- @month = month
- @year = year
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.update
- update_sec
- update_min
- update_hour
- update_day
- # update_mday
- update_week
- update_month
- update_year
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.update_sec
- @sec += 1
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.update_min
- return unless @sec > TIME::MIN
- @min += 1
- @sec = 0
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.update_hour
- return unless @min > TIME::HOUR
- @hour += 1
- @min = 0
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.update_day
- return unless @hour > TIME::DAYS[@day][1]
- @day += 1
- @mday += 1
- @hour = 0
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.update_week
- return unless @day > TIME::DAYS.keys.max
- @week += 1
- @day = 1
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.update_month
- return unless @mday > TIME::MONT[@month][1]
- @month += 1
- @mday = 0
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.update_year
- return unless @month > TIME::MONT.keys.max
- @year += 1
- @month = 0
- @week = 1
- end
- end
- #===============================================================================
- module Game_Time_Updater
- #===============================================================================
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- @update_timer = 0
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.update
- @update_timer += 1
- complete_update
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def self.complete_update
- return unless @update_timer >= TIME::SEC
- @update_timer = 0
- Game_Time.update
- end
- end
- #===============================================================================
- class Scene_Base
- #===============================================================================
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- alias :start_game_time :start
- alias :update_game_time :update
- #--------------------------------------------------------------------------
- # * Start Processing
- #--------------------------------------------------------------------------
- def start
- start_game_time
- start_game_tmod
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def update
- update_game_time
- update_game_tmod
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def start_game_tmod
- @can_update_time_mod = TIME::UDSC.include?(self.class.name.to_s)
- @can_update_time_mod = true if TIME::UDSC.empty?
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def update_game_tmod
- return unless @can_update_time_mod
- Game_Time_Updater.update
- end
- end
- #===============================================================================
- class Window_Time < Window_Base
- #===============================================================================
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def initialize(x,y,w,h)
- super(x,y,w,h)
- refresh
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def widt
- self.width-24
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def modu
- Game_Time
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_game_time
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def draw_game_time
- draw_time
- draw_day
- draw_date
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def draw_time
- text = sprintf("%02d:%02d:%02d",modu.hour,modu.min,modu.sec)
- draw_text(0,0,widt,line_height,text,1)
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def draw_day
- text = "#{TIME::DAYS[modu.day][0]}"
- draw_text(0,24,widt,line_height,text,1)
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def draw_date
- text = "#{TIME::MONT[modu.month][0]}"
- draw_text(0,48,widt,line_height,text,0)
- draw_text(0,48,widt-4,line_height,modu.mday,2)
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def update
- super
- # refresh
- end
- end
- #===============================================================================
- class Scene_Menu < Scene_MenuBase
- #===============================================================================
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- alias :start_time_window :start
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def start
- start_time_window
- create_time_window
- end
- #-----------------------------------------------------------------------------
- #
- #-----------------------------------------------------------------------------
- def create_time_window
- x = @gold_window.x
- y = @command_window.height
- w = @command_window.width
- h = Graphics.height-(@command_window.height+@gold_window.height)
- @time_window = Window_Time.new(x,y,w,h)
- end
- end
- #==============================================================================#
- # http://dekitarpg.wordpress.com/ #
- #==============================================================================#
- end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement