• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

GMS 2.3+ Object's "self" appears as "struct" instead of object type in 2.3

Chai

Member
I'm trying to update my project from 2.2 to 2.3
In 2.2, during object creation, I saved the "self" value of the object to an array. The "self" was saved with the type of the object. So, in the creation of "obj_player", "self" was saved as type "obj_player". Then, later in the game, when I wanted to find "obj_player" in the array, I could go object by object and compare them to "obj_player".
In 2.3, the "self" object is saved as "struct", not "obj_player". It has all the same variables inside it, but the type is "struct" and not "obj_player". So, when I compare all elements in the array to "obj_player" later in the game, I can no longer find the element, because I have "struct" in my array, and not "obj_player". Same goes for any other objects - the "self" is now "struct" instead of the object type.
Again, this happens when I save the "self" value to an array during the creation stage of the object.
Is this a bug? Any idea why this is happening? It's completely breaking my code.

Thanks!
 

Chai

Member
Looks like doing search / replace to any "self" in my code and replacing it with "self.id" did the trick. Thanks, I really appreciate your help :)
 

GMWolf

aka fel666
The thing is self does not evaluate to the id of the instance. Its only interpreted as such when used.

So if you store the self variable, you are just storing the concept of slelf. The id will be determined by whatever entity ends up using that self variable
 
Top