vindaca510

V's Real Time Events v0.2

Jan 30th, 2014
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.39 KB | None | 0 0
  1.  
  2.  
  3. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  4. #                                                                              #
  5. #                             V's Real Time Events                             #
  6. #                                 Version  0.2                                 #
  7. #                                                                              #
  8. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
  9. #                                Written By:  V                                #
  10. #                        Last Edited:  January 30, 2013                        #
  11. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
  12. #                                                                              #
  13. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  14. #                                                                              #
  15. #==============================================================================#
  16. #------------------------------------------------------------------------------#
  17. # ** Disclaimer                                                                #
  18. #------------------------------------------------------------------------------#
  19. #                                                                              #
  20. # This script was intended for Non-commercial use only, if you wish to use     #
  21. # this script in a commercial game please PM me at which ever site you found   #
  22. # this script. Either way please give me credit in your game script as the     #
  23. # writer of this script, and send me a PM abuot the release of the game/demo.  #
  24. #                                                                              #
  25. #------------------------------------------------------------------------------#
  26. # ** How To Use                                                                #
  27. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
  28. #                                                                              #
  29. # * If you do not care to use a value you can replace it with a string         #
  30. #         :time => [second, minute, hour, day, month, year]                    #
  31. #                                                                              #
  32. # * Variables and Switches may have as many assigned to a Time_Event           #
  33. #   as you want.                                                               #
  34. #         :variables => [[variable_id, value], [variable_id, value]]           #
  35. #         :switches => [switch_id, switch_id]                                  #
  36. #                                                                              #
  37. #------------------------------------------------------------------------------#
  38. # ** Description                                                               #
  39. #------------------------------------------------------------------------------#
  40. #                                                                              #
  41. #  v0.1                                                                        #
  42. # ~=~=~=~                                                                      #
  43. #                                                                              #
  44. # * This script is an extention of my conditional checks script. It was based  #
  45. #   on Gump's Time Script. This script can be used to implement real time into #
  46. #   your game via switches and variables.                                      #
  47. #                                                                              #
  48. #  v0.2                                                                        #
  49. # ~=~=~=~                                                                      #
  50. #                                                                              #
  51. # * Bug Fixed.                                                                 #
  52. #                                                                              #
  53. #------------------------------------------------------------------------------#
  54. #==============================================================================#
  55.  
  56. #==============================================================================
  57. # ** V's Real Time Events
  58. #------------------------------------------------------------------------------
  59. #  This module manages customizable features and methods.
  60. #==============================================================================
  61. module V_Real_Time_Events
  62.   Time_Events = {}
  63. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  64. #                                                                              #
  65. #                           Start Customizable Area.                           #
  66. #                                                                              #
  67. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
  68. #                                                                              #
  69. #                        ONLY EDIT THE DESIGNATED AREAS.                       #
  70. #                                                                              #
  71. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  72.  
  73.  
  74.   #=============================================================================
  75.   # * Time Event Set Up
  76.   #=============================================================================
  77.  
  78.   Time_Events["Santa Gift Drop"] = {  :time => ["na", 31, 2, 16, 12, 13],
  79.                                       :variables => [[1, 2], [2, 1]],
  80.                                       :switches => [1, 2, 3, 4, 5],
  81.                                     }
  82.  
  83.   Time_Events["Santa Goes Home"] = {  :time => ["na", 6, 6, 16, 12, 13],
  84.                                       :variables => [[1, 0], [2, 2]],
  85.                                       :switches => [1, 2],
  86.                                     }
  87.  
  88.  
  89. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  90. #                                                                              #
  91. #         DO NOT EDIT PAST THIS POINT UNLESS YOU KNOW WHAT YOUR DOING.         #
  92. #                                                                              #
  93. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.   #=============================================================================
  131.   # * Get System Time
  132.   #=============================================================================
  133.  
  134.   def self.system_time
  135.     systime = { :year => Time.now.strftime('%y').to_i,
  136.                 :month => Time.now.strftime('%m').to_i,
  137.                 :day => Time.now.strftime('%d').to_i,
  138.                 :hour => Time.now.strftime('%H').to_i,
  139.                 :minute => Time.now.strftime('%M').to_i,
  140.                 :second => Time.now.strftime('%S').to_i,
  141.               }
  142.     return systime
  143.    end
  144.                  
  145.   #=============================================================================
  146.   # * Get Event Time by Index
  147.   #=============================================================================
  148.  
  149.   def self.event_time(index)
  150.       evtime = {  :year => Time_Events[index][:time][5],
  151.                   :month => Time_Events[index][:time][4],
  152.                   :day => Time_Events[index][:time][3],
  153.                   :hour => Time_Events[index][:time][2],
  154.                   :minute => Time_Events[index][:time][1],
  155.                   :second => Time_Events[index][:time][0],
  156.                 }
  157.     return evtime
  158.   end
  159.  
  160.   #=============================================================================
  161.   # * Initialize Queued Events by Index
  162.   #=============================================================================
  163.  
  164.   def self.initialize_queued_event(index)
  165.     $game_system.event_activation_states[index] = true
  166.     if Time_Events[index].has_key?(:variables)
  167.       Time_Events[index][:variables].size.times { |i|
  168.         var = Time_Events[index][:variables][i][0]
  169.         value = Time_Events[index][:variables][i][1]
  170.         $game_variables[var] = value
  171.       }
  172.     end
  173.     if Time_Events[index].has_key?(:switches)
  174.       Time_Events[index][:switches].size.times { |i|
  175.         switch = Time_Events[index][:switches][i]
  176.         $game_switches[switch] == true ? $game_switches[switch] = false : $game_switches[switch] = true
  177.       }
  178.     end
  179.   end
  180.  
  181.   #=============================================================================
  182.   # * Events Update? by Index
  183.   #=============================================================================
  184.  
  185.   def self.events_update?(index)
  186.     return false if $game_system.event_activation_states[index] == true
  187.     time = false, st = system_time, et = event_time(index)
  188.     et.each_key { |i|
  189.       if et[i].is_a?(String)
  190.         next
  191.       else
  192.         if st[i] > et[i]
  193.           return true
  194.         else
  195.           if st[i] == et[i]
  196.             time = true
  197.           else
  198.             return false
  199.           end
  200.         end
  201.       end
  202.     }
  203.     return time
  204.   end
  205.  
  206. end
  207.  
  208.  
  209. #==============================================================================
  210. # ** Game_System
  211. #------------------------------------------------------------------------------
  212. #  This class handles system data. It saves the disable state of saving and
  213. # menus. Instances of this class are referenced by $game_system.
  214. #==============================================================================
  215.  
  216. class Game_System
  217.  
  218.   #--------------------------------------------------------------------------
  219.   # * Public Instance Variables
  220.   #--------------------------------------------------------------------------
  221.   attr_accessor :event_activation_states        # Event_Times activation states
  222.  
  223.   #--------------------------------------------------------------------------
  224.   # * Aliasing Method: Initialize Proccessing
  225.   #--------------------------------------------------------------------------
  226.   alias :gsi75214524000  :initialize
  227.  
  228.   #--------------------------------------------------------------------------
  229.   # * Initialize Proccessing
  230.   #--------------------------------------------------------------------------
  231.   def initialize
  232.     gsi75214524000()
  233.     @event_activation_states = {}
  234.     V_Real_Time_Events::Time_Events.each_key { |i|
  235.       @event_activation_states[i] = false
  236.     }
  237.   end
  238.  
  239. end
  240.  
  241. #==============================================================================
  242. # ** Scene_Map
  243. #------------------------------------------------------------------------------
  244. #  This class performs the map screen processing.
  245. #==============================================================================
  246.  
  247. class Scene_Map < Scene_Base
  248.  
  249.   #--------------------------------------------------------------------------
  250.   # * Aliasing Method: Update Proccessing
  251.   #--------------------------------------------------------------------------
  252.   alias :smu65465432  :update
  253.  
  254.   #--------------------------------------------------------------------------
  255.   # * Update Proccessing
  256.   #--------------------------------------------------------------------------
  257.   def update(*args)
  258.     smu65465432
  259.     V_Real_Time_Events::Time_Events.each_key { |i|
  260.      V_Real_Time_Events.initialize_queued_event(i) if V_Real_Time_Events.events_update?(i)
  261.     }
  262.   end
  263.  
  264. end
Advertisement
Add Comment
Please, Sign In to add comment