Thank you for sharing with the community.
If I may offer some constructive feedbac k, I would suggest a better implementation for Do While or Do until loops is not to use a Check If Else loop but rather a Check Once If.
Using your example, like this:
This segregates all of the “Else” actions so they’re outside the “Do While” custom ability. This allows for cleaner code as the subsequent blocks have nothing to do with the “Do While” code. Also, this allows the “Do While” ability to be reused in other places where the code that follows is different.
Using custom abilities and loop recursions doesn’t create any lag. It’s all in how the programer chooses to use the code and in how well the programer understands how the code is executed.
In the 2 isolated code snippets shown above there is a very minor difference in how the Player will execute the code.
Do you see it?
First off, I’ll mention that while in the loop the Change X by 100 block executes every frame until the loop is exited. During the intra-frame execution, the ability “title block” continues directly to the first code block. In this case it’s a Check If, which evaluates the comparison and if true continues directly to the first code block within. In this case it’s a Change X By block. So, while the comparison is true, the Change X By is executed every frame with no “lag” penalty.
Now, in Madi’s example, when the Check If Else is false it continues directly to the first Else block (within the same frame). In my example, when the Check Once If evaluates to false it does not immediately continue. The first block after the Check Once If is executed during the next frame.
Because of that delay, there’s no way to make my example execute exactly the same as Madi’s. My version would be similar to Madi’s if it was written like this with an extra Wait 0 block:
So technically the method I showed does introduce 1 frame of “lag”, but in general I still think it’s a better practice.