Pick by lowest IID

Get help using Construct 2

Post » Thu Aug 22, 2013 7:14 pm

I have a bit of a complicated issue - I need to pick by lowest IID.

Why lowest IID and not just IID = 0? Because I have several instances with body 'parts' and I need to pick a particular instance and destroy the part of that instance with the lowest IID. This IID will not be zero if the instance is the second/third/fourth/etc. copy of a particular object.

How might I accomplish this?

Tagging @vee41 so I can poke his brain on this hehe.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Thu Aug 22, 2013 7:31 pm

Here's how you can do it :

--Some initial picking conditions
--For each object order by object.IID ascending
     -Some actions on the first picked object with the lowest IID
     -Stop loop
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Thu Aug 22, 2013 7:33 pm

Pick your group, do a 'For Each (ordered)', add 'Stop loop' to stop at the first one.

Edit: ack - ninja'd!blackhornet2013-08-22 19:33:47
ImageImageImage
B
71
S
21
G
233
Posts: 3,697
Reputation: 130,370

Post » Thu Aug 22, 2013 7:42 pm

Thanks Magistross! If only thread owners in here could award points to people who answer (kinda like stackoverflow) so they can earn badges!

And good try blackhornet!
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Thu Aug 22, 2013 8:13 pm

Wouldn't 'pick nth instance' where instance is 0 do this as well?
B
24
S
9
G
7
Posts: 756
Reputation: 7,302

Post » Thu Aug 22, 2013 8:23 pm

Would it? And suppose it does... does it have slightly better performance than a for loop that stops on the first iteration?

Because the ordered for loop is working :D
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Thu Aug 22, 2013 9:17 pm

Picking by UID picks the one object that matches.
Picking by IID picks the instance that matches, knowing that the remaining instances are then re-indexed if an instance is destroyed, IE destroy index 2, and 3 becomes 2, 4 becomes 3 etc.
Picking by instance variable picks any matching instances.
Image ImageImage
B
169
S
50
G
170
Posts: 8,292
Reputation: 108,728


Return to How do I....?

Who is online

Users browsing this forum: amazingdream, Yahoo [Bot] and 19 guests