[Solved] Issue with Removing a Child from a Structure Variable in GDevelop

Hello again!

I am encountering an issue when trying to remove a child from a structure variable in GDevelop. Here’s a summary of the problem:

Objective: I need to remove a child from a variable of type structure. There are 2 levels of children.
Issue: When using the “Remove child from structure variable” action provided by GDevelop, the following happens:

  • Numeric sub-children of the child I want to remove are deleted correctly.
  • However, string sub-children of the child are converted to numeric sub-children with a value of 0 after removal.

I have also tried alternative methods, including:
• Using functions from the ArrayTools extension.
• Writing a custom JavaScript function for removal.
• I also tried removing the sub-children of the child I wanted to delete, and the behavior is the same: if the sub-child is of type Number, it is deleted. Otherwise, it is converted to type String with a value of 0.

In all cases, I encounter the same problem.

I have attached screenshots showing:
• The action I used.

• The structure before removal.

• The structure after removal.

Thank you very much for your help!
ADF

It’s possible that after the child is deleted, there’s an event trying to get the value of the child that was deleted. If that’s the case, GD would create the missing child. When in doubt, it’s best to check if the structure exists first before trying to read. It.

1 Like

Thanks a lot for this information Keith, it was very useful.
Thanks to that, I did a lot of tests and realized that the issue came from different lines, especially in loops where I did comparisons without checking if the child existed and when I logged some values in these loops. Thanks!

1 Like