GameMaker Constants

I have a level editor I have created. It loads tiles (Not important right now) and it loads objects like bushes, platforms, switches etc. The locations and other information about these objects are saved to an ini which is then in turn loaded into a separate GMS2 project (The actual game).

Now the problem is that the sprite numbers or ID's what ever you want to call it, have to be the same as the game or I have to write a translation. So an apple sprite may have an ID of 16 so when I load up the ini it will see the ID is 16 then load what ever the ID corresponding to the apple happens to be in the game project.

The issue is that if I add additional sprites, remove or reorder them. I have to do this in both projects or change the translation to point to the new ID.

Is there anyway to get around this. I'm hoping so.

Thanks in advance.
 

Filkata

Member
Or maybe it can be easier to just save the sprite name to the INI if you already have the same sprite names in both projects?
 
Or maybe it can be easier to just save the sprite name to the INI if you already have the same sprite names in both projects?
That's right, you could save the object name as a string using object_get_name(), then when you load it back, use the function asset_get_index() to convert it to an integer id.
 
That's awesome that's what I was looking for thank you. I did not know how to convert a string back into an ID again. I mean I tried it but you can't get the ID by saying sprite_get_number "string name" I did not know about asset_get_index() that's great thanks again.
 
Top