Is there a way of testing if any of a set of objects has or doesn’t have a particular trait (without having to explicitly check each object)?
The scenario is:
I have a container that can contain a fluid object. Objects that can go in the container with the fluid have the trait
wettable_t. If the fluid object is already in the container and the player tries to add another object, I check if the object has the wettable trait; if so it can go in, if not it can’t. That all works fine.
What I’m also trying to do is (in the situation where the fluid object is not yet in the container) check if any of the objects in the container does not have the wettable trait and then prevent the player adding fluid if that is the case. Can I check all the children of a container in that way?
PS - I’ve have a sort of a workaround where I add a non-wettable flag to the container as a whole if any non-wettable objects are added to it (and a subsequent attempt to add fluid to a container with that flag is blocked). But I still can’t work out how to identify which specific objects have the trait (I really want to be able to say 'you can’t put fluid on ‘X’ rather than ‘you can’t do that because one or more of the objects in the container aren’t wettable.’
Perhaps there is a blindingly obvious way of doing this that I’m just not seeing (as happens with depressing frequency)?
I’m not ignoring you but I’ll need to get back to you with the answer to this one. Traits are a work in progress and to be honest I can’t remember if I finished work on an object iterator.
No worries. I’ve now got a workaround with a counter that does what I need it to do ( I can identify how many objects with a specific trait are in the container). I just can’t identify the specific objects at the moment.