Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # [Xp/Vx/Vx-A] Advanced Game Variables
- # Version: 1.01
- # Author : LiTTleDRAgo
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #
- # Example use :
- #
- # You can use it as usual
- #
- # $game_variables[1] = 1
- # $game_variables[1] += 45
- #
- # Or you can use it as self variable
- #
- # $game_variables[[@map_id,@event_id,"A"]] = 1
- # $game_variables[[@map_id,@event_id,"B"]] = "LiTTleDRAgo"
- #
- # You can also use it like this
- #
- # $game_variables[["Number of cats"]] = 108
- # $game_variables[["Name of the cat 1"]] = "Meong"
- # $game_variables[["Owner of the cats"]] = $game_actors[1].name.to_s
- #
- # Etc
- #
- # Enjoy~
- #
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #==============================================================================
- # ** Game_Variables
- #------------------------------------------------------------------------------
- # This class handles variables. It's a wrapper for the built-in class "Array."
- # Refer to "$game_variables" for the instance of this class.
- #==============================================================================
- class Game_Variables
- #--------------------------------------------------------------------------
- # * Get Variable
- #--------------------------------------------------------------------------
- def [](id)
- (id.is_a?(Integer) ? @data : (@data_ex||={}))[id] || 0
- end
- #--------------------------------------------------------------------------
- # * Set Variable
- #--------------------------------------------------------------------------
- def []=(id, val)
- (id.is_a?(Integer) ? @data : (@data_ex||={}))[id] = on_change && val
- end
- #--------------------------------------------------------------------------
- # ● On change
- #--------------------------------------------------------------------------
- def on_change
- $game_map ? $game_map.need_refresh = true : true
- end
- end
- #==============================================================================
- # ** Self Variable Interpreter
- #------------------------------------------------------------------------------
- # This class handles the translation of $game_self_variables into an array
- # so that any individual event can treat its own self_variables as such. It's
- # pretends to be an Array, so far as the interaction requires.
- #==============================================================================
- class SelfVarInterpreter
- #---------------------------------------------------------------------------
- # * Data
- #---------------------------------------------------------------------------
- define_method(:initialize){|mid,eid| @key = [mid,eid]}
- define_method(:"[]") {|vid| $game_variables[[@key[0],@key[1],vid]]}
- define_method(:"[]=") {|vid,val| $game_variables[[@key[0],@key[1],vid]] = val}
- end
- #==============================================================================
- # ** Interpreter
- #------------------------------------------------------------------------------
- # This interpreter runs event commands. This class is used within the
- # Game_System class and the Game_Event class.
- #==============================================================================
- Klass = defined?(Window_ActorCommand) ? Game_Interpreter : Interpreter
- class Klass
- #--------------------------------------------------------------------------
- # ● Alias Listing
- #--------------------------------------------------------------------------
- alias_sec_method :ds_svar_setup, :setup
- #---------------------------------------------------------------------------
- # * Setup
- #---------------------------------------------------------------------------
- def setup(*args)
- ds_svar_setup(*args)
- @self_variables = SelfVarInterpreter.new(@map_id, @event_id)
- end
- end
- $drago_game_variable = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement