For/While Loops - A Sorely Needed Mechanism

For those who know how to code, you should know what a for/while loop is.

For those who don’t, it’s basically a loop that continues repeating until either a certain condition is met (while loop), or until it iterates through something some amount of times (for loop).

They’re incredibly useful for any sort of code-like mechanism, and are almost necessary for a number of systems. For some reason, however, we haven’t actually made a guide on this yet. (I’m still really surprised we didn’t have these a long time ago)

The basic idea is this: we run a task, check if a certain condition is fulfilled, if not, we run it again.

We can actually do this with just this incredibly basic system:

SO HOW DO WE DO IT?

The trigger is the triggering thing. We can also substitute a counter in there instead if we don’t want any delay.

The counter can check for a property or item amount or something. Let’s say we’re using hooked property A. A starts at 10. The counter checks to see if A is above 0. When it is above 0, it will bounce the signal back to the trigger, along with decrementing the property’s hook. It then repeats 10 times, wow!

That’s literally it.
This is insane.
If you’ve ever decided against something because you didn’t have a for loop, time to reconsider!

7 Likes

no responses or likes in an hour is crazy lol

2 Likes

You do deserve better.

2 Likes

What is there to say lol

2 Likes

This guide is actually helpful. Thanks @Shdwy

(looks like you’re having a good day today)

1 Like

Great guide! Loops are so useful for everything. Trigger clocks, super fast speed, etc., etc. Loops have almost endless possibilities! I’m using them right now for my Blackhole simulator in my game! You’re right shdwy, more people should use this. Also, likewise, I’m surprised that none of the coders, including getrithekd haven’t made a guide on this.

4 Likes

Because it was thought to be impossible.

But it isn’t though. Blizzy made a guide utilizing this and so did shdwy in a previous one on why repeaters are trash. I guess not many people know how good and amazing the trigger is.

4 Likes

I would use a counter to make this extra cool and make it support looping through any number of times. Expect a flurry counter-related guides soon!

2 Likes

Oh boy…

Hey shdwy I stumbled across this:

1 Like

bump because important (and spam shdwys notifs ahaha)

note from shdwy

oh trust me my notifs get spammed from the repeater post anyways lol

here have a ping @wingwave

@Shdwy that doesn’t ping me cause its my reply

1 Like