RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Help with XP map IDs and map names

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 83
    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.
« Last Edit: February 06, 2011, 08:55:06 AM by czernobog »

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
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:
Code: [Select]
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*

**
Rep: +0/-0Level 83
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.