Jump to content


Photo

Instance_Id


  • Please log in to reply
7 replies to this topic

#1 Oracizan

Oracizan

    Mutant Dreamer

  • GMC Member
  • 543 posts
  • Version:GM:Studio

Posted 17 October 2011 - 04:32 AM

I'm hesitant to put this into the bug reporting topic as I feel that this is just me being dense...

I've imported a game from GM7.1 in GM4HTML5. Everything went smoothly, but after trying and failing to run my game a few times I realized that all of my instance ids had been changed. Is...is there a way to prevent this from happening? My code references the 'instance_id' frequently and I would be quite distraught if I had to modify all of it. I find it difficult to believe that they would purposefully take away you instance ids when it would be easier and cause less problems just to leave them...but I've been wrong before.

If anyone can tell me about this issue or knows of a solution that doesn't require a massive code rewrite, I'm all ears! Thanks.
  • 0

#2

  • Guests

Posted 17 October 2011 - 07:00 AM

No, sorry. Instance ID's are no longer just "numbers", they are constants. This means you will have to patch them up to the new method. This was a required change for GameMaker:HTML5 as when you merge a project with source control, the ID's were changing all over the place, and projects would fail all the time. Now they can be dynamically allocated at compile/runtime.

#3 Oracizan

Oracizan

    Mutant Dreamer

  • GMC Member
  • 543 posts
  • Version:GM:Studio

Posted 17 October 2011 - 08:23 AM

No, sorry. Instance ID's are no longer just "numbers", they are constants. This means you will have to patch them up to the new method. This was a required change for GameMaker:HTML5 as when you merge a project with source control, the ID's were changing all over the place, and projects would fail all the time. Now they can be dynamically allocated at compile/runtime.


Okay, gotcha. Thanks for your fast response! Renaming all of these will be very icky indeed. :yucky:

When converting from number ids to constant ids, I think it would be helpful if some sort of simple convention was in place i.e if an instance has id '100042' in GM 8.x/7.x, then GM4HTML5 would give it an id of 'inst_100042' or 'i_100042'. That way programmers who referenced instances in their code could just paste 'inst_' or 'i_' in front of their id numbers.

While on the subject of convention, doe GM4HTML5 have any sort of method to its madness when handing out ids? It looks to me like it is choosing numbers and letters at random.
  • 0

#4

  • Guests

Posted 17 October 2011 - 08:29 AM

I'm not sure how they're allocated, but some kind of "random" element isn't out of the question. They are just "handles" now, not indexes...

#5 BorisE

BorisE

    GMC Member

  • New Member
  • 200 posts

Posted 17 October 2011 - 10:44 AM

I have a question related to this: can we reliably "compare" instance IDs. The situation I'm thinking of is where something collides with something of the same type generating two events, and I want to only process one collision (or maybe only play a sound once not twice). It doesn't matter which one is "greater" as long as the result is consistent.

Incidentally I'm guessing that if a game has to reference a specific instance then creation code could be added to write the instance's ID to a global variable?
  • 0

#6 paul23

paul23

    GMC Member

  • Global Moderators
  • 3834 posts
  • Version:GM:Studio

Posted 17 October 2011 - 11:30 AM

I have a question related to this: can we reliably "compare" instance IDs. The situation I'm thinking of is where something collides with something of the same type generating two events, and I want to only process one collision (or maybe only play a sound once not twice). It doesn't matter which one is "greater" as long as the result is consistent.

Incidentally I'm guessing that if a game has to reference a specific instance then creation code could be added to write the instance's ID to a global variable?

instance_create() returns an ID to the instance: this id is unique.. Same with instance_position returning the id of an instance at a certain position.
  • 0

#7

  • Guests

Posted 17 October 2011 - 12:16 PM

An instance ID will not change for the duration of it's lifetime.

#8 BorisE

BorisE

    GMC Member

  • New Member
  • 200 posts

Posted 17 October 2011 - 07:21 PM

An instance ID will not change for the duration of it's lifetime.

I was thinking of what might happen if IDs were replaced by pointers, as this was stated as a likely future change.

Edited by BorisE, 17 October 2011 - 07:21 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users