expression editor - get a value from the "Repeat" event

The repeat event can be more useful if we had a way to get it’s INDEX value in the expression editor and compare it to something.

So for example we repeat a loop 5 times,
On each cycle, the INDEX value increases by 1.
0,1,2,3,4 (for a 0-based index)

on the third time, we make it fire an event by adding the condition:

This can be useful to me to replicate some multimedia fusion behavior with fastloops and the loopindex:

This might not work in gdevelop’s repeat event, because the repeat event can not be named. It is not a function that can be fired x number of times - like other engines.

Actually functions in gdevelop can not be launched X number of times. So I guess to replicate this loopindex behavior,
you have to put a function under a repeat event or something.
But even then you manually have to add +1 to a custom value you made on each cycle or something.
You have to make a crazy setup, which otherwise is already built in for other engines.

Just put a repeat event inside your function? That’s how you should do in every creation tool (read my explanation).
Remember that you can use an expression for the repeat event so you have infinite power on the number of time it is repeated.


Fastloops are not well designed in the way that they are mixing two things in a single object: They are “Functions” (in the way that they can be called from anywhere) and they are also “Loops” (i.e: events which are repeated).

If you want to call something, you’re wanting functions. If you want to repeat something, either do this inside the function, or call the functions multiple times with a repeat event.

Construct2 and GD are implementing this better in the way that they both have separate things for these distinct concepts. You can see that the implemention is more cumbersome in MMF as in your article the loops are not showed nested. You have to “call” the loops to nest them. How complicated it that to nest loops. You are even forced to name your loop - this is a non sense for a programmer.

In GD/Construct, you just add a repeat event, and then another repeat event as a sub event of the first. And you get a nice indentation to visually indicate how events are structured. Exactly like in programming. If you want a counter, set a variable to 0 and increase it in the loop.
It’s not difficult and it’s even better: it forces you to think about why are you using a counter and which name it should have… because if you have a counter, it must have a purpose and naming it help to make this purpose clear! :smiley:

It even seems that, according to this article, MMF lacks the concept of a for each object loop. Some instead of doing like in the article, do it the GD way:

2 events, 2 actions, how sweet is that? :smiley: You even get proper indentation (and “named loop”). And for each event is ultra optimized. Thanks GDevelop! :smiley:

Disclaimer: I haven’t used MMF in a while so maybe they implemented alternatives to fastloop that are existing since when I first used MMF (about 10 to 15 years ago I think).

Is it possible to automatically mass write values from a json file to the values of an object.
Using the repeat command.

In newer versions of multimedia fusion you can address values by their ID number (which means using an expression to determine to which value to write). When you combine that with fasloops and the loop index id, that allows one to very easily (with one line of code) automatically write to all the values of an object. Do it to all the objects in a group (qualifier).
I could do it with both an array and an ini file (ini files are text files like json in gdevelop)

I am curious about this because I am wondering how to do a load/save system where all the objects of a specific group save their values to a json file and then those values can be loaded just as easily.
Without the need to do it manually for each individual variable manually. Just add an object to a group and voala - the rest is automatic.

A fastloop + a loop index approach can automate this! It’s like the bread and butter approach in multipledia fusion for many things.

If you have the newest version of clickteam fusion, I will share with you the source file so you can decide for yourself if the functionality can be replicated in gdevelop and if it can’t - what would be the feature that it needs.

I’m not sure we are still talking about repeat event anymore: Multimedia Fusion may have a may to get “address values by their ID” which I’m not sure what it refers to but I guess that you can get a list of all variables stored into an object.

Maybe the feature you’re talking about is interesting, maybe not, but be assured that this feature has nothing to do with fastloop! Don’t confuse this feature and the fact that fastloop is a just a loop with a name.

Much like a repeat event + variable index (or a better a foreach event, or better a while event) are the bread and butter approach in GDevelop for many things… and in all programming language. :mrgreen:

Put it in another way: Every single construction you’re making with a fastloop can be reproduced by a repeat/foreach/while event (and eventually a function but most of the time you don’t need to use one) - it’s normal because fastloop [size=120]is[/size] a repeat event, it’s just named otherwise.

Now, if you are using, inside this fastloop, a feature of MMF that seems missing in GD, maybe that this feature that you really want to speak about since the beginning. Sadly I don’t have MMF, sorry :frowning:

Ok, you are right. Instead of requesting the feature that I do need, I have written a request for features form another engine which I think will help me achieve it in gdevelop.
You can close this thread.

That’s ok, maybe the right solution to this thread would be in fact to have a wiki article that is a translation of the article you came up with, but with GDevelop events. :slight_smile: This could help other people make the transition from “fastloops solutions” to “GDevelop solutions”. :slight_smile:

it would be nice to have these explained in the wiki - that is a good idea :slight_smile:

this is my actual feature proposal - fitting more with the current design: