I wouldn't use "for each" for going through larger families. Instead try "Pick object by value", where the object would be your family. It will pick all objects the expression you enter applies to.
I did a little speed test for that - in my project I have the family "Ships".
I displayed an object counter in my debug console and told Construct to create fighters (member of ships) until the fps drops below 60.
In my code I did:
> for each (Ships)
Ships('status') = "Idle"
Tell ships to move to random position
Set Ships('status') = "Roaming"
My object count went up to close to 1.600 before my FPS dropped below 60.
However, when I tried this:
Pick (Ships) by value 'Status' = "Idle"
My object count went up to close to 16.000 before my FPS dropped below 60.
So this is clearly faster.
in addition to the fact that you need a trigger it will add all Idle objects to the SOL JanMan needs to loop though each instance of the family so that it will only pick one at a time.
Also Jan man why do you constantly need to be writing to the .ini file? if the player leaves the layout just write the values then constantly writing to the disk is slow.
we also talked about this on the chat yesterday. If you have each object in the family with a private variable name your writing function would look like this.
->on function Save Positions
->for each [familyname]
-->ini.writevalue(npc('name'),"x") value: [family name].x //the group is the NAME private
variable of your NPC family Item = x
-->ini.writevalue(npc('name'),"y") value: [family name].y