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

  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)