Class: Game_SelfVariables
- Defined in:
- scripts/00600 Script_RMXP/03100 Game_SelfVariables.rb
Overview
Note:
This script should be after Interpreter 7
Hash gérant les variables locales. Des variables propres à l'évènement, Permet de ne pas devoir utiliser de variable de jeu pour gérer ce qui est propre à un évènement Dans les scrpit, la variable globale $game_self_variables contient les variables locales
Instance Method Summary collapse
-
#[](key) ⇒ Object
Fetch the value of a self variable.
-
#[]=(key, value)
Set the value of a self variable.
-
#do(key, operation = nil, value = nil)
Perform an action on the specific variable and return the result.
-
#initialize ⇒ Game_SelfVariables
constructor
Default initialization.
Constructor Details
#initialize ⇒ Game_SelfVariables
Default initialization
13 14 15 |
# File 'scripts/00600 Script_RMXP/03100 Game_SelfVariables.rb', line 13 def initialize @data = {} end |
Instance Method Details
#[](key) ⇒ Object
Fetch the value of a self variable
19 20 21 |
# File 'scripts/00600 Script_RMXP/03100 Game_SelfVariables.rb', line 19 def [](key) return @data[key] end |
#[]=(key, value)
Set the value of a self variable
25 26 27 |
# File 'scripts/00600 Script_RMXP/03100 Game_SelfVariables.rb', line 25 def []=(key, value) @data[key] = value end |
#do(key, operation = nil, value = nil)
Perform an action on the specific variable and return the result
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'scripts/00600 Script_RMXP/03100 Game_SelfVariables.rb', line 32 def do(key, operation=nil, value=nil) @data[key]=0 unless @data.has_key?(key) case operation when :set @data[key]=value when :del @data.delete(key) # Numeric when :add @data[key]+=value when :sub @data[key]-=value when :div @data[key]/=value when :mul @data[key]*=value when :mod @data[key]=@data[key]%value when :count @data[key]+=1 when :uncount @data[key]-=1 # Boolean when :toggle @data[key]=!@data[key] when :and @data[key]=(@data[key] and value) when :or @data[key]=(@data[key] or value) when :xor @data[key]=(@data[key]^value) end # Return the data return @data[key] end |