# How exactly do you deconstruct the Tiled Map Editor exported tile ID?

I am trying to build 2D maps with Tiled Map Editor for my game, and I export them under text format, so a tile can look like this:

1,2,3,15,2,12,2

5,23,1,6,2,3,4,6

and so on, for many rows. In this link you can see an example of a map, to get a better idea.

Now let's say I have 3 layers, each using its own tileset. The numbers in the layer represent the ID of the tile, basically the number of the tile in the sheet. If grass is the 2nd tile, then the ID is 2, and so forth.

However, as you can see in the link, different tilesets will export different IDs per layer, notice how in the object layer I can have IDs such as 81, when in fact the ID is only 1, so it adds up 80 or so.

Since I am trying to make my map system as flexible as possible, I need the real ID in order to make some calculations. How does tiled export these sort of IDs? I simply want to determine what number to substract in order to get the id, like so:

tile.id = currentid - something_strange;

You are using Tiled map editor, but not using the TMX file format, right? I believe the something_strange comes from the first tile GID in the given tileset. Just save the tilemap as TMX and you should see something like:
 <tileset firstgid="49" name="nameoftileset" tilewidth="128" tileheight="128" spacing="2" margin="1">

something_strange == firstgid