IF two objects with the same var value exist -> action

Get help using Construct 2

Post » Wed Aug 12, 2015 8:31 pm

I don't understand why this didn't work, i want to do this: If two or more objects with the same variable value exist then action, i need to use families.

Image
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Wed Aug 12, 2015 8:39 pm

you could use something like

1/ system pick by comparaison object fruits families when fruits.animationName= "Orange"
- system compare two value fruits.pickedcount >=2 ---> Set text to "I like Oranges"
Image Image
B
23
S
13
G
135
Posts: 871
Reputation: 70,345

Post » Wed Aug 12, 2015 8:46 pm

MadSpy wrote:you could use something like

1/ system pick by comparaison object fruits families when fruits.animationName= "Orange"
- system compare two value fruits.pickedcount >=2 ---> Set text to "I like Oranges"


Now Its Working, thank you!!!!! i learned something new today ;)
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Wed Aug 12, 2015 9:06 pm

Then wrap MadSpy answer in a for each.

For each fruits
+(empty sub-event)
--Set local var currentFruit to fruits.animationName
+Pick all fruits
+Pick fruits where fruits.animationName = currentFruit
+Compare two values : fruits.pickedCount >= 2
--Do something
--Stop loop
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Wed Aug 12, 2015 9:18 pm

Lol I had prepared a little capx to show you the method (with local variable and pickedcount for the last)
Image Image
B
23
S
13
G
135
Posts: 871
Reputation: 70,345

Post » Fri Aug 14, 2015 2:59 am

MadSpy wrote:Lol I had prepared a little capx to show you the method (with local variable and pickedcount for the last)

thanks for the example but think if i have hundred of different fruits, i cant use local variables.

i tried this again and now didn't work, the last object didn't update the Boolean, if i have two oranges or more i want to set the Boolean duplicated true but only to oranges or other duplicated objects, how this can be done? i cant use local variables because if i have a lot of objects in a family then will be a lot of local variables.

Image
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Fri Aug 14, 2015 11:21 am

It seems that this solved your situation.
B
30
S
9
G
3
Posts: 280
Reputation: 4,212

Post » Fri Aug 14, 2015 3:45 pm

sielxm3d wrote:It seems that this solved your situation.

No, the example below isn't worked
B
9
S
3
Posts: 142
Reputation: 1,108


Return to How do I....?

Who is online

Users browsing this forum: Anonnymitet, tarek2 and 25 guests