So I want to check how many tiles named “coin” I have in my map.
This is my attempt:
[lua]
local i = 0
for tile in map.layer[“tileobjects”].tilesInRect(map.width*0.5,map.height*0.5,map.width,map.height) do
if tile.name and tile.name == “coin” then
i = i+1
end
end
print("coins in map: ",i)
[/lua]
Loop took ~1 minute and I got 0 in result when there were supposed to be 9 coins…
So is there other method to do this?