Thank you.
p Object.constants.sort
class Data
p self.constants, self.private_methods - Object.private_methods, self.public_methods - Object.public_methods
end
Expand to see the code.
I tested this above all the other scripts. Apparently the last Data does exist, but has no constants, private_methods or public methods (I removed the methods from the object class and got an empty array).
I have no idea what this class is for.
What did you mean make $data_classes into a module?
Also, check this out if you haven't seen it:
#==============================================================================
# ** Modules.Game_Data (1.0) By SephirothSpawn
#------------------------------------------------------------------------------
# * Description :
#
# This modules lets you add new $game_data objects to your game with a simple
# call script within your script.
#------------------------------------------------------------------------------
# * Syntax :
#
# Adding new $game_data object
# - Game_Data.add_game_data('variable_name', 'Class_Name')
#
# Example : Adding new Game_Database to your $game datas.
#
# - Game_Data.add_game_data('$game_database', 'Game_Database')
#==============================================================================
MACL::Loaded << 'Modules.Game_Data'
#==============================================================================
# ** Game_Data
#==============================================================================
module Game_Data
#--------------------------------------------------------------------------
# * Instance Variable Setup
#--------------------------------------------------------------------------
@additions = []
@variable_names = []
#--------------------------------------------------------------------------
# * Additions
#--------------------------------------------------------------------------
def self.additions
return @additions
end
#--------------------------------------------------------------------------
# * Add Game Data
#--------------------------------------------------------------------------
def self.add_game_data(global_variable_name, game_object_class)
# If Variable Name Used
if @variable_names.include?(global_variable_name)
# Print Error
p global_variable_name + ' already used. Please use a different ' +
'variable name.'
return
end
# Add Addition
@additions << [global_variable_name, game_object_class]
end
end
#==============================================================================
# ** Scene_Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :seph_macladdgamedata_scnttl_cng, :command_new_game
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
def command_new_game
# Original Command: New Game
seph_macladdgamedata_scnttl_cng
# Pass Through Game Data List
Game_Data.additions.each {|vg| eval "#{vg[0]} = #{vg[1]}.new"}
end
end
#==============================================================================
# ** Scene_Save
#==============================================================================
class Scene_Save
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :seph_macladdgamedata_scnsv_wsd, :write_save_data
#--------------------------------------------------------------------------
# * Write Save Data
#--------------------------------------------------------------------------
def write_save_data(file)
# Original Write Save Data
seph_macladdgamedata_scnsv_wsd(file)
# Pass Through Game Data List
Game_Data.additions.each {|vg| eval "Marshal.dump(#{vg[0]}, file)"}
end
end
#==============================================================================
# ** Scene_Load
#==============================================================================
class Scene_Load
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :seph_macladdgamedata_scnld_rsd, :read_save_data
#--------------------------------------------------------------------------
# * Read Save Data
#--------------------------------------------------------------------------
def read_save_data(file)
# Original Read Save Data
seph_macladdgamedata_scnld_rsd(file)
# Pass Through Game Data List
Game_Data.additions.each {|vg| eval "#{vg[0]} = Marshal.load(file)"}
end
end
Expand to see the code.
This is actually in the current MACL, just not sure if anyone has seen it (and since we are on the discussion of data).
No more aliasing Scene_Title, Scene_Save and Scene_Load, just a simple single line code and it does it all for us.
Although I am going to modify this so:
In Scene_Title, some game objects will be created before the original command_new_game, others after. They will also check for a ":setup" method and run it if the method is defined.
Scene_Save, data saved before or after original call.
Scene_Load, data loaded before or after original call. It will also check for a ":load" method here and call it if it is found. Might be overkill, but I want to make it completely possible for anyone to add a new game object with only 1 line of code.