Rei Self Variable Versi: konvert-an Tipe: Variable
Pengenalan
Cuma Hasil Convert dari thread ini : http://www.rpgmakerid.com/t155-rei-self-variable
Iseng aja dipost karena lagi bete
Scripts
Code:
#============================================================================== # ** Rei Self_Variable by reijubv V.2.0 (Rewritted) #------------------------------------------------------------------------------ # This class handles event's owned variables. # The instance of this class is referenced by $game_self_variables. #============================================================================== class Self_Variables #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize @data = {} end #-------------------------------------------------------------------------- # * Get Self Variable value #-------------------------------------------------------------------------- # How to use : Write this to event's script command # $game_self_variables[[$game_map.map_id , @event_id]] #-------------------------------------------------------------------------- def [](key) return @data[key] == nil ? 0 : @data[key] end #-------------------------------------------------------------------------- # * Set Self Variable Value # value = value you want to set in this variable #-------------------------------------------------------------------------- # How to use : Write this to event's script command # key = [$game_map.map_id , @event_id] # $game_self_variables[key] = value #-------------------------------------------------------------------------- def []=(key, value) @data[key] = value end end
class Scene_Title alias_method :or_new_game, :command_new_game
def command_new_game; or_new_game $game_self_variables = Self_Variables.new end end
class Scene_Save < Scene_File alias_method :or_write, :write_save_data
def write_save_data(file); or_write(file) Marshal.dump($game_self_variables, file) end end
class Scene_Load < Scene_File alias_method :or_read, :read_save_data
def read_save_data(file); or_read(file) $game_self_variables = Marshal.load(file) end end