Structures and child in [for each child] event

I believe I’m using the most recent version.(5.2.175) Can someone verify this?
I swear I used to be able to build structure name in the for each child event

This works:

But this does nothing and I’m wondering if it’s because of the new way variables are handled.

It also creates an empty structure
image

If I store the label text into a variable it also works

I confirm you have to use VariableString to access the child of a structure.
Or you can write something like Structure[“” + YourVariable] - this is to force the variable to be read as a string.

This will be fixed in the next version.

My issue isn’t the variable part. It’s when I used the label text of a button object. Sorry, I should’ve made that clearer.

It works if I save the text to a variable but not if I use the object expression within the structure brackets.

Indeed it’s not related. Any chance you can try with a previous GDevelop version (get it from GitHub)?

I can’t find any issue with this - any chance you could send me a stripped down version of your project (or the project itself) so I can have a look? Thanks!

I haven’t installed an older version yet but here’s a new simple project that tests the structure name in 4 ways with 4 buttons.

Try me:

Source:

The structure after clicking the 3rd button, a child with the name “” is created.

In practice, each button would have a different text.

Super useful! I confirm I can reproduce the problem, your example is really really invaluable here.

This is not due to the new variable syntax it seems - as it’s actually not used here (and I verified it will work in a new bugfix release if we write for Button4 Player[LabelText], as long as you declare LabelText. Don’t try this now because it does not work yet - it’s another bug that is being fixed).

I’ve opened the example with GDevelop 5.2.172 and it also fails with the case Button3.
This is due to the usage of Button3 inside the for each variable. It’s a pain and your workaround (storing it in another variable) is good. It’s not a regression but I’ll try to understand what’s going wrong.

Thanks again - this was super helpful to have a real test case. Should speed up the bugfix.

You’re welcome. I appreciate the quick response.

I’m sorry this is an old post but the problem seems to persist.
The expression doesn’t work with [object.ObjectName()] but it Its works if storing the object name in another declared variable [VariableString(ObjectNameVariable)]
Is it working as intended ?

Can you post a screenshot of your events for context?


This one not working.
The text object and event are here to check if the for each child event is working.


This one working with the workaround . Set a Variable with the name of the entrance object and use it in the for each child event expression.

It’s tough for me to tell what’s going on because I don’t know which objects are in the group and which objects are in the layouts. Here are a couple of common problems which may or may not apply.

Two weird things with GD. Objects don’t get deleted until the next events.

So this, might not work as expected.

But moving the events so the other events aren’t in the same event or a direct sub event. Would most likely work.

Like this.

The other GD oddity is Layouts. The opposite is true for them. The object don’t exist until after the event that added them.

So, this might not work as expected.

But this should

In the first case, since the objects aren’t deleted immediately, if you set or read something related to the objects, it might apply to the old objects instead of the new objects.

In the 2nd case, the objects might not exist yet. So, trying to read a value related to them might result in the wrong vue being returned.

My only tip is to check the value of the properties and /or variables and see if it’s reading the right objects. You could use the debugger or add a text object and add the values to it.

It’s late. Im tired. If this is still unanswered tomorrow, I’ll try to test using object.Name in a fer each child and as a variable. But Im just too tired for this to make much sense without testing it.

thank you for your answers.
to be clearer: all the events above work correctly apart from “for each child”.
Unless it is not allowed to use the name of an object directly in the expression.
I did a little test.

the first directly uses the name of the “reactor” object in the expression of the “for each child” event. this one doesn’t work.
the text of text objects does not change

in the second try I added a variable scene in which I copy the name of the object with an additional event.
using this variable in the event expression “for each child” (instead of the object name directly) it works.

The bug does appear to be back.

I tested it with a structure with an array.

I used 2 text objects named NewText1 and NewText2 and an object named Test. I used both methods.

Only the 2nd method that used a variable that contained the object name worked.

My result. NewText1 (left) NewText2 (right)
(The word Text was the default text for the text objects)

You might get a quicker response if you start a new thread. People tend to ignore old posts and posts with a lot of replies. You can include a link to this post.

Another option is to also post to the Github page.

https://github.com/4ian/GDevelop/issues

Thank you for the example. It’s an issue in the code generation of the “for each variable”. The generated code doesn’t give the object instances to the expression.

Thank you for reporting an issue. It should be fixed in the next release.