How do I get top 3 highest variable

Get help using Construct 2

Post » Tue May 09, 2017 9:35 am

Hi there,

I have 6 variables and i want to display the top 3.
I know that a loop is required but how do i implement one so that it compares all 6 and return top 3?

Thanks!!!
B
12
S
3
Posts: 15
Reputation: 734

Post » Tue May 09, 2017 11:40 am

What kind of variables ?
Instance Variables ?

https://www.dropbox.com/s/yxispg1xtgkzk ... .capx?dl=0
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue May 09, 2017 11:55 am

Global variables ?
https://www.dropbox.com/s/nglkwdp0b9ak4 ... .capx?dl=0

You should not do that btw. Rather store the variables in array only, to start with.
An array is no more then a global variable holding a list of values.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu May 11, 2017 12:33 am

@99Instances2Go
Hi,

Yes, its global variables.
So you are suggesting that i store it in an array first then sorting them out?
B
12
S
3
Posts: 15
Reputation: 734

Post » Thu May 11, 2017 7:36 am

Not first, all the variables only in the array.

Say you have the variables .. (that you would make into globals)

var1
var2
var3

Now
You can make it yourself easy, if you want to. Make a new event sheet. Call it "Indexes". (dont even need to include it)

In that new event sheet "Indexes" add the following globals.

global var1 (number) = 0
global var2 (number) = 1
global var3 (number) = 2


Now storing a variable to the array (if the array is big enough) goes like this.
Array > action > Set at X > ... index= var1 (the global in the other sheet) ... value = what you wanna store

To use a value in the array, use its expression
value = Array.at(var1)

Now you can sort as i showed you.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi and 18 guests