Is it possible to use the Array "Contains" with a single conditional?

I wanted to know if a specific integer array contains any value other than 0.

By default all items of the array in question are 0. During gameplay any of them could go up to 1 ~ 999.

Would it be possible to stick something special into Contains’ “item to check for” to have it return true only if something other than 0 is found?

Right now I’m doing check using a foreachloop. But it seems kinda taxing for such a simple thing.

I don’t think there is a other solution, except you sort your array by decreasing order after you change a item.

You can write a own function so you only have one node in your BP, but I think there is no other solution than a for loop to check all elements in an array

Rather than checking your array in a loop, implement delegates. In blueprints they are Event Dispatchers.

You would implement the dispatcher on your game element that modifies your array to fire. Then you implement your logic whenever that event dispatcher fires, is a lot more efficient.

Hey -

If you have your get array node selected and drag out from there you can add a “Max of Int Array” node which will search the array and return back both the max of all entries in the array as well as the index the entry was found at. If the array is empty then it returns a value of 0 at index -1.

cheers

Awesome. Thanks a lot, . is much cleaner than the for loop check. Works nice!

Hey thanks a lot for the help, MajinSephiroth.
I apologize for not being more clear about how I had that for loop implemented. Actually, I was initially doing the for loop in an event bound to a dispatched event. I use dispatchers sparingly, but I take it I should use them more often for inter-object communication.

, thanks for the help. Interesting, I’ve never tried to sort an array before. If I did as you specify, then I’d need only check the item of the first or last entry in the array which is cool. I will remember . Thanks!