Instant cloning method (with recursion and Check If Else)

Project example

Code

Credits

Recursive cloning method from ThinBuffaloSr

A while ago ThinBuffaloSr shared a method of cloning with recursion:

Single-frame recursive abilities from Petrichor

Petrichor posted a trick for single-frame recursive abilities on the app. It puts the recursive ability inside the Else section of a Check If Else block.

(Explanation from comment block in the code)

When checking if it should run an ability, the player needs to be sure to avoid infinite loops, since they will cause womps. To do this, it looks inside of the ability. If it sees just a recursive ability with no blocks or with only instant blocks, it won’t run the code. It only looks in the first ability it sees though, so it will not notice that this block contains recursion, since that is in the else statement.

Explanation

So if you put the recursive part inside the Else, it will run instantly too.

There may be some delay if working with very high number of clones, but otherwise it seems near instantaneous. I haven’t verified yet how long it takes, but would be worth doing some tests.

The other nice thing is that you can put code in the first part of Check If Else that you want to run for all clones of that object, after cloning is done. E.g. setting appearance, position.

Possible Limitations

12 Likes

Cool method! I’ll prob use it.

5 Likes

Excellent method! I use this a lot - probably the best out there!

7 Likes

Cool. I did notice there’s a limit to how many times a recursion can occur. I tried recursion 1000 in the fun trick project, which did work when playing the project and took 17ms, however, it crashed (womped) when restarting the project.

5 Likes

Oh have you used it with Check if Else before? It is faster than using it with Check Once if.

I’d used this method before, but not with the Else change.

4 Likes

I have not, actually. This seems like it would be faster. I’m definitely gonna use this for future projects. Would you like me to credit you?

4 Likes

Nah it’s ok you don’t need to. But if you do give credit, it would be worth crediting Petrichor and ThinBuffaloSr too – the two combined techniques are from them.

6 Likes

It’s a neat trick.

It seems to be about as fast as the

“when total clones < number { clone object }”

method.

Edit: it’s slightly faster, it cloned 900 objects in ~ 9 frames (with a little bit of lag), versus 11 frames with the method above.

4 Likes

Nice tutorials!

Just want to add, if you have secret blocks and are targeting a certain number of clones, it’s even easier – all you have to do is “when total clones < target clones AND clone index = 0, clone times (target - total)” – also takes one frame.

4 Likes