I need to trigger an action when all instances of the same object have the same value for a variable. And I can't figure this out.
How do I do what I wanna do? I wish I knew.
Develop games in your browser. Powerful, performant & highly capable.
Any more details? Are the variables random? Or counting up steadily until reaching a limit?
+ Always -> Set global('average') to 0 + For each object -> Add object.Value('variable') to global('average') + Compare: global('average') / yourNumber is equal to number of objects -> Do your thing [/code:615x1f1t] Maybe? If not then it might help to have more information. By the way, this will only work reliably if there is a maximum value for your object's variables, and you are checking if the numbers are all at max.
Or, taking Deadeye's example further:
+ Start of comparison -> Set global('sample') to Random Object.value('variable') -> Set global('TestFlag') to 0 + For each object -> Compare object.Value('variable') to global('sample') -> If Variable<>Sample then set global('TestFlag') to 1 + Compare: global('TestFlag') -> If 0 do you thing![/code:28sb9ktb] In short, you set a flag to 0, choose one of the objects at random and take that value as a sample, then loop through all objects checking the contents against the sample each time, setting the flag to 1 if the compare on any of the objects fails. This way, the only way the flag will still be 0 after the looped compare has taken place is if ALL the variables of the object are the same. Krush.