A "For" Loop for Coders

I was thinking of making an encoder/decoder, and I came into this idea. So first, you want to have a trigger that triggers on “Trigger this trigger again”. Set player collision and visibility to no.
Then, in the block code, put this:
image
Property “X” is a player-scoped, number property.
Here are the trigger’s settings:


So what happens is that the game checks to see whether “X” is equal to the length of the property text. Then, if it isn’t, the game does whatever every you want it to do, and then increases “X”. Then it triggers the trigger again. And repeats this cycle until “X” is equal to the length of the text property. Once it is, it breaks free of the loop and then does the other stuff you want to happen.
Edit: I haven’t tested this. Might not work.

3 Likes

you should probably explain it a bit more

1 Like

This is recursion. You can learn more about it here.

1 Like

This is very helpful for the system I’m making that has to have encoding/decoding!

1 Like

Noice guide

Yeah that’s true this helped me

1 Like

You don’t need blocks for this, you can just use a checker.

3 Likes

this is very interesting! seems fun

Yeah. Its odd how as we get better at gimkit we actually start to discover blocks. Make really intense block code systems and then try to avoid blocks but still make the system to reduce memory.

1 Like