Comparing multiple variables?

Get help using Construct 2

Post » Sun Mar 18, 2012 3:05 pm

Hi!

Is there a way to compare more then 2 variables at the same time in one event?

I would like to compare the laps of 8 vehicles and pick the winner from it.
I already have everything set except for this comparisment.
I think it might be done with an expression i dont know about yet.
Before i make a complex version through events to achieve this, i would like to know if there is a simple way.
I search the forum but came back empty handed.

Any help would be great!

Thanx
B
56
S
20
G
13
Posts: 778
Reputation: 13,204

Post » Sun Mar 18, 2012 3:57 pm

I don't know of any way to compare several variables in one event, but here's how I would've done it with a somewhat simple repeat loop:

Example - Pick Highest Value (Compare 4 variables)
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Sun Mar 18, 2012 4:03 pm

You may use max() expression. Jailson2012-03-18 16:10:01
B
228
S
6
G
8
Posts: 86
Reputation: 12,295

Post » Sun Mar 18, 2012 4:07 pm

Thank u both!

@Jailson
It looks like this max expression is what i need.

@Nimtrix
Im currently working in 80.2 so i cant open the CapX file.
But i'l keep in in my example list!
B
56
S
20
G
13
Posts: 778
Reputation: 13,204

Post » Sun Mar 18, 2012 4:17 pm

hmmm I would do something like
[code]On what you want
Local UIDfirst = -1
Local lapTime = -1
System: foreach vehicle
    System: lapTime = -1
      -> System: set lapTime to vehicle.lapTime
      -> System: set UIDfirst to vehicle.UID
    System: lapTime > vehicle.lapTime
      -> System: set lapTime to vehicle.lapTime
      -> System: set UIDfirst to vehicle.UID[/code]
and you should end up with the UID of the vehicle with the shortest lapTime in the UIDfirst local variable.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Mar 18, 2012 4:50 pm

I happen to keep some old releases on a memory stick, so here's a 80.2 version, should you need it.

Same example, 80.2
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Sun Mar 18, 2012 8:51 pm

Thanx Yann & Nimtrix!

It helps Allot
B
56
S
20
G
13
Posts: 778
Reputation: 13,204


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 14 guests