A question about picking

For questions about using Classic.

Post » Tue Dec 01, 2009 1:26 am

Hello,
I still seem to get a bit confused about some of Construct's inner workings. Maybe you guys can help me out a bit.
I have a family "Ships". I want to pick all ships that have their private variable "status" set to "Engaged" and then run several checks and actions on them.
Does it work like this?

[code:l4jytlz0]
Pick Ships by comparison: Ships('status') = "Engaged"
Move to Enemy...
[/code:l4jytlz0]

or do I have to do it like this:

[code:l4jytlz0]
Pick Ships by comparison: Ships('status') = "Engaged"
For each Ships
Move to Enemy...
[/code:l4jytlz0]

Meaning: When I "Pick object by comparison", does it loop through all objects picked automatically within that event, or do I have to do the "For each object" to loop through them?
And: Does the For each then loop through all the Ships, or just the ones I filtered through picking in the parent event?
B
3
G
3
Posts: 14
Reputation: 903

Post » Tue Dec 01, 2009 2:56 am

You don't need to use "Pick by comparison" in this case because there is a built-in expression for private variables. Just do like this:

[code:3ns3kf75]
+ Family.Ships: Value 'status' Equal to "Engaged"
-> Do stuff
[/code:3ns3kf75]

You get that just by selecting the Ships family in the New Condition window and picking "Compare a private variable." It's even hilighted in yellow.

And no, there is no need for a loop. The action will be performed on every member of the Ship family that meets the criteria in the condition.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Dec 01, 2009 3:27 am

Ah, thanks. That's awesome :)
B
3
G
3
Posts: 14
Reputation: 903


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests