Looping through grid

Using the grid extension, i need to loop through a global variable structure and add an item to the grid for each item in this structure, for an inventory. For example i have a 3 column 5 row grid and 4 items in my global variable structure each with seperate names. I also have an object which has animations that are the same as the item names. What i want to do is add items to this grid by looping through the global variable, adding items into the grid structure in a linear fashion so that the global variable can contain an inventory which can then be visualized in a grid.

This is the current setup and the bottom part is how i would like it to work but is certainly not working right now.

As you can see the 4th item has overflowed into the next row as there are only 3 columns. The idea is that hopefully this can be used in a system with a different grid size without changing the code but if not that is ok.

If you have any other questions please let me know.

Did you try connecting it through events too? That’s worked for me before.

I dont really understand what this means, im objectively using events to code the game but i need this solution to loop through a grid

Update on this

im not particularly sure what doesnt work here so if anybody can please help that would be great

I figured out that you cant loop through global variables so i fixed that, but it still doesnt even create the objects

I know this is not what you asking for but, just in case, there’s an extension that do this.