Unable to add additional values to array

I am attempted to fill an array “Enemies” with structures containing information I’ll need handy later on in my events sheet.
‘Patrons’ is a group of ten, largely identical, sprite objects. When any Patron is alive its info should be copied into a structure “Enemy,” and that structure then added to the end of “Enemies.” This should result in an array filled with ten sets of data. Instead I can never manage to get more than 1 child in my array with this setup. I have tried several major and minor tweaks to this system with no solution.
The issue seems to be that “Add variable Enemy to array variable Enemies” simply doesn’t function as advertised within the context of “Repeat for each instance of ___”. I can get it to work as advertised in other contexts, but not within “Repeat for each instance of ___.” “Add value to an array variable” also seems not to work.

I don’t see anything that jumps out to me as wrong. How many Patrons Alive boolean are set to true.

I created a test project that adds the text and X position of text objects (NewText) to an array. It then uses for each child to add the structures in the array to another text object. (output) I assigned a random number to the NewText objects.

. List is my array and Stuct is a structure with 2 children, X and Text.

This is my output. It added the X and Text values to an array and then the matching values to a text object.

.

1 Like

Thanks!

Every instance of Patrons has it’s variable Alive set to TRUE.

I deleted what I had in my first post and rebuilt some of it following what you had in your screenshot. It didn’t change anything. Still left me with an array with 0 children.
I then created a test project with all the necessary elements and copy/pasted the event group that I just wrote - which didn’t work in my full project - and it worked in the test project.

So, another data point on the graph.

More changes within my original project file.

  1. Moved the Event Group from an external sheet to my scene’s main event sheet. Array length still 1. (Array length 0 was my mistake from printing to NewText before adding any Thing to Things. Fixed that.)
  2. Removed an Object variable Enemy from each Patrons. Array length still 1.
  3. Create a group ParticleEmitters from all the particle emitters in my project. Modified the code to fill the structure Thing with CurrentParticleCount() and Flow(), then copy Thing into Things. Works like a charm.

Perhaps the issue is with the group Patrons, somehow.
4. Deleted and recreated the group Patrons. No change.
5. Stopped using “For Each Instance” to fill Thing. Instead using separate events to fill Thing and copy to Things for the first three of my patrons. Tried filling Thing with ForceX() and ForceY(), as well as with custom object variables .Number and .Health). Yields an array of length 3, but with each slot empty.

I may be overlooking something simple, but this one’s really puzzling me.