Download

Request: For loop break node

As a small quality of life improvement, it would be great if we could have a dedicated “break loop” node with a single input execution pin. When execution reaches this node, it simply breaks to the “completed” pin of the current loop. If it is used outside of a loop it would do nothing and execution would terminate the same as when execution reaches a dead end.

This should help clean up graphs which use for loops that make use of breaking. May remove the need to differentiate between “for loop” and “for loop with break” nodes. Ideally this node would also work with while loops.

To be honest, Your request is way too specific and messy, so didnt read it thru.
But for loop is a macro, you can double click on it to see how it works, it’s made of simple bool gates, you can build your own with any alternative/extra functionality. I have like 15 different for loops with extra parameters or some weird functionality to fit my needs.

I’m not sure what was messy about my request, and I think it’s suffice to say that specificity is a good thing. It’s not very useful for you to reply to threads which you don’t actually read.

I actually hadn’t realized that for loops were implemented as macros, thanks for pointing that out. That does explain their current sort of ad-hoc implementation and messy approach to breaking, but it isn’t useful in the context of this thread (besides the implication that it would be slightly less than trivial to implement this request). As a side node, it also sounds like there is something fundamentally wrong with your “coding” style if you need so many different for loop variations.

My request wasn’t just for my personal want or need, it was a suggestion to improve the implementation of for loops in blueprints.

Break like you want is not possible without creating a lot of clunky stuff to support it, you can open for each loop macro and see how and why its not trivial at all.
My code base is fine, there are cases where you need some extra stuff, like boolean output for if break was hit or for loop with skip index increment for array filtering. Also i have few different for loops without local variables which use ref outside a macro.