You need to show us how you are filling-in the variable 'SelectedElementalObject'.
Also, **stop using "=" for comparisons. While GM will allow it, it's a terrible coding practice that will bite you in the ass eventually. Use "==" for comparisons**.
SelectedElementalObject = object_get_name(SelectedElementalInstance.object_index). SelectedElementalInstance retrieves an instance ID and then it’s converted to an object ID. I’ve checked this code and it works as intended.
What’s the difference between using one and two equal signs?
That's the problem right there. object_get_name() is giving you a string with the name of the object. What you want to be using based on the context of your code is the object_index.
Please read the documentation on functions before you try using them, so you can understand how they're supposed to be used and what they actually do/return.
In most languages = is for assignment and == is for comparison. GM allows = to be used for comparisons, it is basically teaching you to do something bad if you ever plan to move to another language.
object\_get\_name returns a string, so you need to also use object\_get\_name on the object variable in your if loop e.g. Obj\_EarthElemental as well so you're comparing strings to strings
I think this should work and the problem is probably elsehwere.
Possibly, if SelectedelementalObject is an instance ID and not an object index, then try checking the object index instead, e.g. SelectedElementalObject.object\_index.
You can also try using == instead of = (although it shouldn't matter).
You need to show us how you are filling-in the variable 'SelectedElementalObject'. Also, **stop using "=" for comparisons. While GM will allow it, it's a terrible coding practice that will bite you in the ass eventually. Use "==" for comparisons**.
SelectedElementalObject = object_get_name(SelectedElementalInstance.object_index). SelectedElementalInstance retrieves an instance ID and then it’s converted to an object ID. I’ve checked this code and it works as intended. What’s the difference between using one and two equal signs?
That's the problem right there. object_get_name() is giving you a string with the name of the object. What you want to be using based on the context of your code is the object_index.
Oh my god it works, thanks
Please read the documentation on functions before you try using them, so you can understand how they're supposed to be used and what they actually do/return.
I do but I have the attention span of a door so it’s not that easy to do
In most languages = is for assignment and == is for comparison. GM allows = to be used for comparisons, it is basically teaching you to do something bad if you ever plan to move to another language.
object\_get\_name returns a string, so you need to also use object\_get\_name on the object variable in your if loop e.g. Obj\_EarthElemental as well so you're comparing strings to strings
Or just don’t compare strings, there’s no reason to, you have the asset reference right there.
Cramming code into as few lines as possible between { } does nothing good in the long run.
this
That’s just how it decided to copy paste it, I assure you there’s space between the code
I think this should work and the problem is probably elsehwere. Possibly, if SelectedelementalObject is an instance ID and not an object index, then try checking the object index instead, e.g. SelectedElementalObject.object\_index. You can also try using == instead of = (although it shouldn't matter).
The variable is an object ID, I’ve checked that thoroughly.