on start of layout
compare array.AT0
for "x" from 0 to 4 (lets say your inventory width item has 5 slots width only visually)
for "y" from 0 to array.at0 (but unlimited height cells)
action>
create object on
inventoryslot.X + loopindex(X)*item.width
inventoryslot.Y + ((loopindex("x") + loopindex("y")) /2) * item.height
if the value at array0 is equal to 10 for example you should have 5 columns width of apple icons and 2 rows
the above example is not that useful when you have large ammounts of items like in a crawler dungeon rpg thing... but does it jobs if you have a small inventory of like 5-10 items... i think there was a example for a stacking inventory like dungeon crawler type around here... doing a insert/pop array thing but its been years and the tutorials area got sort of mixed up. happy hunting and hope it helps.
here is one that looks like the one i was thinking at ... maybe is newer than the one i was thinking at
but has item categories and stacking inventory.
rpg inventory + equipslots c3p