[Solved]How do I apply functions to many instances in Array?

Just started using Construct 2? Post your questions here

Post » Fri Jul 10, 2015 1:34 am

Hi,

I have an (7,7) array with instances with values of 1 or 0. I need to apply a function based on all instances that have a 1 value on them. I tried tokenat, Compare Value, Compare Current Value, For each element, but couldn't find a way to say:

For each instance with value 1 --> get the X and Y of each of them
--> set variable a to X
--> set variable b to Y
--> Call function (that uses each a and b obtained)

My objective: if an instance of the array has a value 1, all instances around it must get a value floor(random(0,2)). If it turns out as 1, the process repeat again until a limit (a global variable) is achieved. If the limit is not achieved, the process needs to repeat again at each instance with a 1 value.

Do you have any idea of how I could manage that?

Anyway, thank you for your time!

Best regards,
Lucius
Last edited by LuciusCD on Fri Jul 10, 2015 2:36 pm, edited 1 time in total.
B
8
S
2
G
1
Posts: 15
Reputation: 664

Post » Fri Jul 10, 2015 2:34 pm

Got it!

It is a combined use of he Array condition "For each element" followed by the "Compare Current Value" and he will get the all the instances at value 1. The problem now is that he doesn't respect the condition "if global variable r<=16, call function at instances with value 1" . He keeps calling the function even if r>=16. But that is another matter. This doubt was solved!
B
8
S
2
G
1
Posts: 15
Reputation: 664


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 4 guests