How do I get variables of multiple objects.

Get help using Construct 2

Post » Wed Sep 21, 2016 9:36 pm

I have three selected objects. The have the same variable, for example "Number", but the value of the variable differs.
How can I get the highest and the lowest variable's value of selected objects?
How can I get the values of the variable of multiple objects if they are selected?
I need the values to multiply them.
B
20
S
4
Posts: 51
Reputation: 1,104

Post » Wed Sep 21, 2016 10:05 pm

I know how to get the highest and the lowest values.

My example below has 3 green sprites that have the UIDs of 3,10 and 11.

Each have 'Variable1' values of 15, 35 and 1.

The UID 10 is the highest and 11 is the lowest.

https://www.dropbox.com/s/p61a7l8qikfak ... .capx?dl=0

Getting the values of the variables from multiple (selected) objects sound like they will need array, functions and possibly families.

Could anyone else look into this issue further?
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Wed Sep 21, 2016 10:35 pm

Any picked. Dont forget the exceptions.

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

Post » Thu Sep 22, 2016 12:01 am

That is again an amazing skill, 99Instances2Go. Thank you very much for the information. (I learned something new again. :D)
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Thu Sep 22, 2016 12:21 am

You can also do a For Each loop (first pick the relevant instances by preferred method) - Set maxvaluevariable to max(maxvaluevariable,object.value) or Set MinValueVariable to min(minvaluevariable,object.value).

This will basically go through each picked instance and if the instance value is higher (or lower) than the previous highest or lowest, it will update the variable. Otherwise, the last value stands.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458


Return to How do I....?

Who is online

Users browsing this forum: DharmaOne and 26 guests