It's somewhat complex. The set is basically the folder name of the tile set, and the name is the tile name as per the TILES.TXT file. As an example, the following code gets the IDs of the water tiles for each of the 3 tile sets and stores them in some globals.