Using repeat/while loops instead of copy & pasting

File keeps crashing and corrupting the file when I copy and paste the nested function below and tweak it.

Instead of copying and pasting, is there some kind of repeat function I can use?

Not sure what’s wrong with copypasting, everyone uses it. :slight_smile:
Does this look like an acceptable numerical value to you? :rofl:

On a side note, there’s a repeat function, and a while function. Press the big + button on top. Be aware that the while function will freeze the game if not used properly.

If you use a variable instead of “15” “30” ect,
You only need 1 event that uses the variable
And another event to set the variable.

“!x”, “xname”, and “_Ball” are unique stand-ins so I don’t replace any of other values when using find and replace. I replace “!x” with a number value that increases by a value of one for each nested event I copy & paste.

The problem I’ve had with all the copying and pasting is GDevelop starts crashing and the JSON file corrupts. Then I revert to the old version. Before crashing the JSON file had something like ~1.5 million lines of code :sweat_smile:. Maybe this is a separate issue, but I think it’s just because the file is too large.

I think repeat and while loops are probably the way to go.

I think this could help. I forgot there was a VariableString() expression. The, “15”, “30”, etc. are tied to a slider where you put an exercise ball into an inventory slot, then it picks up the time. So maybe if I declare above in a separate variable that counts the numbers (15sec, 30sec, 45sec, 1min, 2min, 3min, 4min, 5min) and issues a number for each (0,1,2,3,4,5,6,7), which will should make it easier to iterate through.

I don’t know how I’d iterate through the “WorkoutSet.0.duration” global variable though. Is there a way to add a variable that increments inside of the name of the variable, e.g. “WorkoutSet.[increment_variable].duration”?

You are very close.
Dynamic access to children:
GlobalVariable(workoutset[GlobalVariableString (increment)].duration)

You can pass numerical values using variableString ()

1 Like

Thank you! I’m going to play around with this.

If you can reproduce the issue consistently, please head to #gdevelop-general:bugs-reports describe reproducing steps, and we’ll see if it can be fixed.

Just posted: GDevelop crashes and JSON file corrupts when duplicating nested event too many times

1 Like