12-07-2010, 09:00 AM
You have to paste your CMS below the map looping feature.
In your CMS, the following code :
creates a Hash object named "$map_infos" that stores the maps names (from the database) for their ids. As it is directly written in a class and not in a method, this code is executed when the game is launched (the scripts are read from the top to the bottom).
--> it becomes easy to retrieve a map's name by its id to display it in the menu.
"$map_infos[key]" is an instance of the class "RPG::MapInfo", and "$map_infos[key].name" calls the "def name [...]" method in that class.
If this script is above the map looping script, the names in that Hash are full names, including brackets.
But in the map looping script, the "def name [...]" method in the "RPG::MapInfo" class is rewritten, so that all brackets and their contents are removed :
That's why you need to have this code before the creation of the Hash object, and so paste the CMS below the map looping script.
In your CMS, the following code :
Code:
class Scene_Title
$map_infos = load_data("Data/MapInfos.rxdata")
for key in $map_infos.keys
$map_infos[key] = $map_infos[key].name
end
end
--> it becomes easy to retrieve a map's name by its id to display it in the menu.
"$map_infos[key]" is an instance of the class "RPG::MapInfo", and "$map_infos[key].name" calls the "def name [...]" method in that class.
If this script is above the map looping script, the names in that Hash are full names, including brackets.
But in the map looping script, the "def name [...]" method in the "RPG::MapInfo" class is rewritten, so that all brackets and their contents are removed :
Code:
class RPG::MapInfo
# defines the map's name as the name without anything within brackets,
# including brackets
def name
return @name.gsub(/\[.*\]/) {""}
end
[...]
Some scripts :
Working on :