GMS 2 Question about spawning instances of children


So I have this system where all items (weapons, consumables, etc.) are children of an overarching obj_Item. It's children are obj_Weapons, obj_Consumables, etc. which in turn are the parents to obj_SteelSword, obj_BucketOGoo, etc. which are actual items. I wanted to have an item bank that basically just spawned in one of each item, read from their variables then deleted all of them. I have it now just listing out like
itemList[0] = instance_create_depth(x, y, 5000, obj_NoWeaponEquipped);
itemList[1] = instance_create_depth(x, y, 5000, obj_WoodenSword);
for every single item in the game. then at the end I iterate through itemList and delete them all. I was just wondering if there was some way to spawn in every child of the obj_Item object or maybe even the obj_Weapons and obj_Consumables objects so I don't have to add an item to this bank every single time I add an item to the game. Is there some way to iterate through all children of an object and spawn each one in or something like that? I haven't seen anything like that but I very easily could have just missed it.
Thanks for any tips!


So if I understood this right, you spawn the instances because you want to read their certain values - like weapon damage, armor value, etc - to some centralized data structure?


šŸ§ *penguin noises*
GMC Elder
Why not have all the data in a centralized data structure to begin with? Even a 2D array / ds_grid is good enough for most use cases (item ID on the x axis, different data on the Y axis, use macros/constants to improve readability)


Well I mean I could but I don't really see how that's any more efficient than what I have. It's pretty much the same thing. It still has the same issue of having to go back and add each item to the list of items every time I make a new item. I was just wondering if there was any way to do something like instance_create_all_objects_of_type(obj_Item) in order to create one of every obj_Item's children. There may not be any way of doing that automatically, but I was just hoping there would be to make it slightly easier on myself.