Pick by lowest IID

0 favourites
  • 7 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • 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.

  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Pick your group, do a 'For Each (ordered)', add 'Stop loop' to stop at the first one.

    Edit: ack - ninja'd!

  • <img src="smileys/smiley2.gif" border="0" align="middle" /> 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!

  • Wouldn't 'pick nth instance' where instance is 0 do this as well?

  • 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

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)