[Solved]How do I - Have the system pick the largest amount

Get help using Construct 2

Post » Mon Aug 17, 2015 4:10 am

I'm going to assume that I need to be using the System pick conditions, but I can't wrap my head around getting the system to pick "the best" out of all of the selections.

I'm using "System pick sprite where sprite1 HP > sprite2 HP"
and I'm also using "pick sprite1 Nth instance" to pick the first available one but....

I can't wrap my mind around how I would get the system to choose the largest one.

I imagine its something along the lines of.... "For every sprite1...." and maybe ... grab it's HP value, and set it to a Global Var HPVALUE_Max

And then grab another sprite1, and if that value is larger than the previous, replace it... and repeat for all...

Then go to the sprite1 who's HP = HPVALUE_MAX , and of course pick the Nth instance of it incase of multiple's ....?

And then.... use that to "Pick the best" ?
Sorry for my rambling, I think it helped to type it all out.

But I still wonder, is this how you would do it? (Hello reader!)
As usual, I'm just wondering if this is "pretty much correct" and I'm not looking something.
Last edited by SwatHound on Mon Aug 17, 2015 5:59 am, edited 1 time in total.
B
6
S
2
Posts: 60
Reputation: 1,242

Post » Mon Aug 17, 2015 5:00 am

@SwatHound

there is a Pick Highest/lowest option under Instance Variables for an object...

so, Sprite > Pick highest/lowest > choose highest and HP

Another way would be

System > For Each (ordered) > Sprite > Sprite.HP Descending then stop the loop after the first one...
but you would only do it that way if you were looking for a value that wasn't an instance variable, like the Sprite with the highest Opacity, or Angle or some other attribute.
B
98
S
34
G
20
Posts: 438
Reputation: 17,815

Post » Mon Aug 17, 2015 5:56 am

AllanR wrote:@SwatHound

there is a Pick Highest/lowest option under Instance Variables for an object...

so, Sprite > Pick highest/lowest > choose highest and HP

Another way would be

System > For Each (ordered) > Sprite > Sprite.HP Descending then stop the loop after the first one...
but you would only do it that way if you were looking for a value that wasn't an instance variable, like the Sprite with the highest Opacity, or Angle or some other attribute.


Ah hahaha. AND THIS IS WHY I ASK QUESTIONS!

THANK YOU! LOL I never .... used that.. function.. haha.. lovely I see it now yes yes... I must have gone over that a thousand times.

Thank you @AllanR ...
B
6
S
2
Posts: 60
Reputation: 1,242


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, JackTYGA, worm1 and 24 guests