I am working on a TBS and for the battles I want to teleport the player to a new map. I want to have a few (3 for now) different maps for each tileset and randomly select between them. So far I have been able to determine the current map's tileset name, randomize it, and edit it into a usable format. I've named my battle maps accordingly.
ex. for the grassland tileset I have made three battle maps named
Grassland 1
Grassland 2
Grassland 3
If the current map uses the grassland tileset I will end up with a variable containing one of these as a string.
Say I get @stringvariable = "Grassland 3"
How can I retrieve the Map ID of the battle map named Grassland 3
Is there any way to identify the map's ID number based on the map's name?
I assume it has something to do with the data class, but I haven't been able to find it. Any help would be greatly appreciated. Thanks in advance.
edited for clarity (hopefully lol) + the below
I am beginning to think that the only way for my system to work is with a carefully preplanned and hard coded array with symbols. If you don't know the answer to my question, but have a suggestion of an alternative, please feel free to suggest it.
The information you want is stored in MapInfos.rxdata which is a hash mapping map ids to MapInfo objects. A MapInfo object contains the name of the map, but it does not contain the id of the map.
You can do something like this to get the information you want:
def find_map_id(map_name)
$map_infos ||= load_data('data/MapInfos.rxdata')
for key, value in $map_infos
return key if value.name.downcase == map_name.downcase
end
return 0
end
*hugs*
Thanks a lot. Your suggestion works perfectly. I'm not experienced enough with the ruby to have figure that out on my own. I was about to scrap the whole plan.