Problem with "Child Exists" condition

Hi, I have a big problem :disappointed_relieved: :disappointed_relieved: :disappointed_relieved:

I add a string to an Array and everything works correctly (I attach an image of the inspector).

When I check the existence of the child nothing happens. How is it possible? Is it a bug?

I’ve read a lot on the forum but it seems like my solution is correct. I tried replacing “0” with strings, but to no avail!

The child exists is for structures like for arrays you need the condition right above it number of children

Arrays start at zero. So, the count will always be +1. If you want to know if 0 exist it would be number of children is greater than 0 meaning there is at least 1 child, number zero for an array. Or if you prefer =>1.

For child 1 it would be >1 or =>2 whichever is your preference. There would have to be a 0. So, it would be 0 and 1.


Thanks so much for the very quick response.

I put “0” but I tried with any other value (1, 2, etc…), but the condition never occurs (I know that arrays start with 0).

Why doesn’t the condition work? How should I correct?

Thank you very much!

Let me explain better, if it helps.

I created a loop that reads the entire array. When it finds a child that contains a certain string, then that child will be deleted.

Unfortunately “Child exists” never occurs

As I said you would need to count the children. child exists would only tell you if “item” existed in gemstone.archevio. If you want to know if the child in the array exist then you need to use number of children

I don’t mean to talk down to you or anything. I always try to explain things as if the person is new to the subject. I never know the person knowledge level. I hope this helps.

I’m used to calling array items elements. Gdevelop uses children.

1 Like

Thank you very much. I’m quite familiar with GDevelop (my game is an almost complete visual novel). But this is my first time using arrays.

I will try to carry out tests as you recommended and then I will write the results here.

Thanks again

1 Like

This is my loop. I read each child and compare if the string is the one I’m looking for.

OK. Then you would use child count is >0 to make sure the is at least 1 child and then repeat child count times it’s also an expression with the same name.

I think it’s easier to search from the end though because starting from the beginning will cause the array to shrink.

If there’s a 0,1,2,3 and you delete child 2 then child 3 becomes 2. So, in that situation you wouldn’t need to increase the counter.

I’ve done similar things. If you start at the end (meaning count-1) then it doesn’t matter if everything above your counter moves up a child number.

It’s all up to your preference.

I see. If that’s under a repeat number of children then I don’t think you need to check if the child exists. You’re already taking the shift into account. So, I think you just need to remove the if exists line. I’ll test it myself because I’m easily confused with arrays but it looks good.

OK. I had to test my logic. This is one way. I used at the beginning to test it. I also used scene variables bc that’s what I’m used to and it makes it easier to snapshot. (I would also use the variables setup screen but this captures all of my setup)

1 Like

Perfect! It works!!! :dizzy:

Thank you so much for your support and patience! :smile: :smile: :smile:

1 Like