Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

GMRoomPack

Package GameMaker rooms and load them as you please · By YellowAfterlife

room_pack_store_instances does not store instance ID?

A topic by Kehler Creations created Dec 27, 2020 Views: 233 Replies: 3
Viewing posts 1 to 2

For a long time I have been trying to solve a severe problem, without success. Every ds_list_find_index() returns -1 for instances created using this method:

room_pack_store_instances(ds_Chunk_Objects[CX, CY] /*List supposed to hold IDs for Chunk CX,CY*/ );
room_pack_include_layer(CL_Layer[CL_LoadStage[n]] /*Load a specified layer*/ );
room_pack_load_map(World[?name],X,Y);

After a while, I tried drawing all the content of the list ds_Chunk_Objects[CX, CY], and it does not seem to store the instance IDs. Instead, it stores every single variable and value of the instance. Each new line is the next index in the data structure.

Is this normal behavior? I suspect that it is not, since room_pack_store_tilemaps() appears to work fine.

Developer (1 edit) (+1)

If you are using GMS 2.3+, GMRoomPack stores instance-struct references (the ones you’d get by doing var a = self;). You can pull the ID out of them via list[|i].id if desired.

Thanks, I have managed to get it working with that :)

But is there any way for me to change GMRoomPack to just return IDs? I imagine it uses quite a bit more ram to save all that data, which I don't need. Perhaps it's negligible, but the game has thousands of instances loading in, so it might still make a meaningful difference.

Developer(+1)

It does not use more RAM, these are references to structs that already exist inside instances. That’s how GML works now.

You can find these two lines in GMRoomPack’s GML file

var l_list = room_pack_raw_store_instances;
if (l_list != undefined) ds_list_add(l_list, self);

and change the second line to use id instead of self, but I do not think you’ll win anything whatsoever in doing so.