Can see you are a bit confused about IID and UID and how to do it, so here is how you do it correct no matter how many cactus you have and how big you tilemap is, with a better explanation.

IID and UID: Are not something that are unique for tilemaps. In fact all objects you add to your project will be assigned these. My best advice for now just to completely forget IID and only think of UID, I have used C2 for quite a long time and have yet to run into any problem where IID would be useful.

UID is a "Unique identification number" (I think that what it stands for) but even if it doesn't you can think of it like that. Its different for all objects so you will never have any sprite, tilemap, button etc with the same number. This make UID very good for picking things, because you know it will always only pick one.

If you look at the screenshot below of the correct code for exactly what you want to do.

The loops are nested, which is the normal way of going through a lot of elements like in a tilemap or an array.

If you look at the tilemap, the tile in the top left corner have a position of 0,0 the one to the right is 1,0 next 2,0 and so on.

Since the program doesn't know where in the tilemap we have placed the cactus, we need some way to let it know. So we use loops to go through each tile to see if its a cactus. Since we don't know where to start we "set" the position to (X,Y) by default (You wont actually do this.)

The first loop "Tile X" will start at 0.

So now it would be (0,Y)

Since the next loop is a sub event to the first loop and goes through the Y and also starts at 0, we get. (0,0)

So it checks if (0,0) is equal to 15, which in this case it ain't so It loops again. However since "Tile Y" loop are the last one it will continue this one first before going back to the "Tile X" loop.

So next time it will be (0,1),(0,2),(0,3).........until it reach the end of Y. In this case I have set it to int(Tilemap.Height / 32), this is because this will always give us the correct number of tiles to check in Y, the reason I divide with 32, is because each tile is 32x32 and int simply does that we always get an integer as you cant be sure that the tilemap height is always an integer if you scale it and then divide it with something, but the loop requires an integer to work or will go into an endless loop, which will make you have to force close the program, so that's not good, but happens quite a lot.

So if the tilemap is 128 pixels in height we divide it with 32 and get 4.

So the loop will run from 0 to 4, so in fact if we were to be 100% accurate we could subtract 1 from it as the tilemap starts at 0. So it should actually only run from 0-3 as the loops include both 0 and 3.

But anyway when it reaches the end of "Tile Y" loop it will go back to the "Tile X" loop and increase that one, so now you would get

(1,Y)

And it would go into the "Tile Y" loop again and it would then be (1,0) and then keep doing that until also X reaches it limits.

Hope that didn't confuse you