Good day,
I have a game mode that changes a struct once the postlogin event begins.
I have created a function to search the struct for an empty slot to input the players details.
My loop is as such. ‘Null’ is the empty value, and the function searches the array to find the next index that holds a ‘Null’ and outputs that index to be used. If the search is constantly false, then the index produced will me -1 which will allow me use that for other reasons.
Cheers for the quick reply, I still dont fully understand why the original loop didnt work. But the slight tweaks you recommended worked. Cheers.
you said proper for the non-break concept.
I know my array may not be large, but would it not be best practice to stop the loop to save on running extra steps that are not needed?
The function have a strict start and finish points. It starts at “begin”(abstract term, in your case it’s the violet Find Empty Array Index node) and ends at return node (can have several return nodes). That means that as soon as your execution comes to the return node, the function execution is finished. Including no more loop interations.
The way you think about it, is probably coming from the main EventGraph, where there is not return nodes and you have to break the loop explicitely. But for functions is isn’t the case
you said proper for the non-break concept.
I know my array may not be large, but would it not be best practice to stop the loop to save on running extra steps that are not needed?
I know it might be very minute in difference
So, based on above, it’s the other way round: the immediate return will save you from one extra break call