montagneyaya wrote:I will verify if there is a monster on a tile, I use entitiesAt(level, x, y) but how i see if the iterator is a monster ?
I had the same problem looking for monsters and other things. The trick is to find a keyword or method that is only attached to the entities in which you're interested. For example, only monsters have the
setAIState method. So if you iterate over the entities returned and eleminate those without this method, you'll have a list of monsters. You might also want to filter on other things like finding all objects in a square - so look only for objects with the
getWeight method. You can look at the entity name too, for example, and find all doors, but finding all monsters or objects without looking at methods is difficult. You can write a dedicated routine for each requirement, but I wrote a generic find and filter routine instead which is found at
viewtopic.php?f=14&t=3985&p=41224&hilit=Lark#p41224 that will do the trick.
To find all monsters, just use
monsters = findAll(self.level, self.x, self.y, {":setAIState"})
See the original post for more details and for the code.
Have Fun!
-Lark