Compare 2 children from different arrays

How do I…

I want to check if a certain position (which i store in an array) is contained in a different array, and then check
worldData.deleted[n3][0] != deleteBlockSplit[0]

What is the expected result

It shouldnt spawn the object if the position is stored inside the worlddata.Deleted. worlddata.Deleted contains a lot of different children which all contain 3 children in them (thats how i store the position of mined blocks) but i wanna check if the deleteBlockSplit position is the same as one of the children

What is the actual result

It ignores the check and spawns the object anyway

Related screenshots


this works buut its not exactly what i wanted

How big is the array?

For clarity, you could use an array of structures. The structure could have children named X, Y and Z. That wouldn’t really change the method.

You could store the X, Y, Z in an array or a structure. Both methods would be similar. I don’t know if one is better than the other

For my example I created a structure called World. No children, just World as a structure.

I added a few 3D objects named Box

It stores the position of the boxes as structures names of World. The value isn’t used. It’s just a way to create the structure.

For testing I used the X, Y, Z of the existing objects. I added an object at runtime after the locations were added to the structure just to test it. The object created at runtime wasn’t in the array, so it wasn’t deleted when I touched it.

This is what the structure looks like after the object locations are added to it.

You could use a similar approach with an array. You could search for the element with for each child or the search function in the array tools extension.

This time World is an array and Index is a number variable used to store the index. If the array tools search can’t find the text then it returns -1.

IDK if either method is what you’re looking for or would scale up to a large world.

It can have 100s of children, and im also using it in a lot of systems in my game (placing, breaking, loadingdata, etc.) soo i wont by changing it into a structure. But i could check if child with certain values (xyz) exists and then continue for there.

Well idk what the best solution would be im just going to look for some way to check if theres a child in the array with certain values

1 Like