Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # ICF-Soft Time Utility Version 1.0
- # For XP to Ace versions.
- #-------------------------------------------------------------------------------
- # It uses game variables to store and count time.
- # Time is stored as minutes.
- # Also stores date on variables and update when map changes.
- #-------------------------------------------------------------------------------
- # Scripted by ICF-Soft [http://icfsoft.blogspot.com.es/]
- # Commercial use avaiable.
- # Credit to ICF-Soft.
- #===============================================================================
- # This header must be included with script, in english or spanish.
- #===============================================================================
- # Usage:
- # -To store a time into a variable use ICFUTIL::GetTime(varid)
- # -To check how much time has passed use ICFUTIL::GetTimeSince(varid,resid)
- # -To check how much hours has passed use ICFUTIL::GetHoursSince(varid,resid)
- # -To check how much days has passed use ICFUTIL::GetDaysSince(varid,resid)
- #
- # Params:
- # -varid: the variable where store and check the time.
- # -resid: the variable where store the result of time passed. If omited returns
- # the value directly (for scripting purposes).
- #===============================================================================
- module ICFUTIL
- #===============================================================================
- # Do not touch this
- Scripts = {} unless defined? (Scripts)
- Scripts["time"] = 1.0
- # Configuration
- # Aditional variables where store full date. Usefull for map events.
- # Format is [Year,Month,Day,Hour,Minute,Weekday,Month-Day].
- # To skip a param put 0.
- DateVars = [6,0,0,3,2,4,5]
- # Weekday starts with sunday as 0, monday as 1 ... and saturday as 6
- # Month-Day is a special format because events can use only one variable
- # per page. So it needs a combined one. Is Month*100 + Day
- # Some Month-Day Examples:
- # - 101: January 1st
- # - 102: January 2nd
- # - 201: February 1st
- # - 211: February 11th
- # - 1001: October 1st
- # - 1010: October 10th
- #-------------------------------------------------------------------------------
- def self.GetTime(varid)
- $game_variables[varid] = Time.now.to_i / 60
- end
- def self.GetTimeSince(varid, resid=0)
- return Time.now.to_i / 60 - $game_variables[varid] if resid == 0
- $game_variables[resid] = Time.now.to_i / 60 - $game_variables[varid]
- end
- def self.GetHoursSince(varid, resid=0)
- return GetTimeSince(varid)/60 if resid == 0
- $game_variables[resid] = (Time.now.to_i / 60 - $game_variables[varid])/60
- end
- def self.GetDaysSince(varid, resid=0)
- return GetTimeSince(varid)/1440 if resid == 0
- $game_variables[resid] = (Time.now.to_i / 60 - $game_variables[varid])/1440
- end
- def self.GetDate
- $game_variables[DateVars[4]] = Time.now.min if DateVars[4] > 0
- $game_variables[DateVars[3]] = Time.now.hour if DateVars[3] > 0
- $game_variables[DateVars[2]] = Time.now.day if DateVars[2] > 0
- $game_variables[DateVars[1]] = Time.now.month if DateVars[1] > 0
- $game_variables[DateVars[0]] = Time.now.year if DateVars[0] > 0
- $game_variables[DateVars[5]] = Time.now.wday if DateVars[5] > 0
- $game_variables[DateVars[6]] = (Time.now.month*100 + Time.now.day) if DateVars[6] > 0
- end
- end
- #===============================================================================
- #===============================================================================
- class Game_Map
- alias pre_time_setup setup
- def setup(map_id)
- pre_time_setup(map_id)
- ICFUTIL::GetDate()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement