Information
By: Rez
Asked: April 03, 2012
Answered: December 31, 1969
Worth: 10 Member Points
Question answered:
The member points were handed out this way:

Iasper (10)
SpectreNectar (0)
sirxemic (0)
gml: how do you get an object to return it's name?

I don't know how to be more detailed than that...

I want the name of an object to equal something. How would I go about finding said name in code?


Dev - Warning
Dev - After editing rating, make rating display change
Dev - When editing, update "edited" column
Dev - Restore deleted comments
Dev - Display deleted comments if mod (hidden, then with dropdown)
Dev - After deletion or during edit, make rating dropdown appear again
Dev - Stricter rating rules. Prevent user from rating again
Dev - Pages
Dev - Reporting
object_get_name(object_index)
Posted by Iasper April 03, 2012 12:56 - 1.1 years ago
| [#1]

I tried that but the whole idea is that I get the object itself to return the name, so writing out object_get_name(object_butt) really defeats the purpose. And object_get_name(self) doesn't work.
Posted by Rez April 03, 2012 12:57 - 1.1 years ago
| [#2]

"self" doesn't work because it defines the instance, not the index, and that is what you need. It's also why you have to use object_index. If you make an object called obj_butt display a show_message with object_get_name(object_index), it will display obj_butt, while string(obj_butt) would display 0 (or whatever other index it is)
Posted by Iasper April 03, 2012 13:01 - 1.1 years ago
| [#3]

*Slaps head* of course! Thanks man.
Posted by Rez April 03, 2012 13:02 - 1.1 years ago
| [#4]

Apparently:
Code
var it;
    it = instance_copy(false);
show_message(string(object_get_name(it)));


Won't work either :3
Posted by SpectreNectar April 03, 2012 13:07 - 1.1 years ago
| [#5]

Why would it, Spectre?
Posted by sirxemic April 03, 2012 13:34 - 1.1 years ago
| [#6]

I posted after the solution was explained. I was wondering why as well. As to why I just thought it was a problem with gm not being able to get the name of the current instance hence I tried a clone ;)
Seemed like a good idea at the time.
Posted by SpectreNectar April 03, 2012 15:32 - 1.1 years ago
| [#7]

Recent Activity
 
Active Users (0)