View Issue Details

IDProjectCategoryView StatusLast Update
0027114Runner SuggestionsFunctionsPublic2018-05-09 16:29
ReporterEric BuneseAssigned To 
PriorityMediumSeveritySuggestionReproducibilityN/A
Status NewResolutionOpen 
Summary0027114: Suggestion: Functions: [GMS2] Getting the instance's element name as set in the room editor
DescriptionWith the addition of layers, it is possible to properly identify different types of assets placed in the room editor. However, we cannot retrieve the given name.

Suppose we're placing a few instances of the same object in a room, but we still want to properly identify all of them. The current way to do this is assign a different value in a variable in each instance's creation code.
If we could properly retrieve the object's element name as assigned in the Instance layer, this could be done directly without having to add code we do not see unless we open the instances properties.
Additional InformationThe attached screenshot shows the assigned element name for an instance.
The following code could then return the name as a string;

///@descr returns the object element name
///@arg instance_id

if (instance_exists(argument0))
{
 with(argument0)
  return "back" // returns the assigned element name in the layer the
                // instance is in
}
else return ""
TagsNo tags attached.

Activities

Eric Bunese

2017-07-14 16:12

Updater  

Screenshot_1.png (3,202 bytes)
Screenshot_1.png (3,202 bytes)

Piotr Gnys

2017-07-17 13:26

Updater   ~0054272

Last edited: 2017-07-17 13:27

View 3 revisions

It's not a string name, it's an MACRO (constant) which is replaced by instance ID on compile time.

So, in this case "name" == string(id).

You can check this by writing "show_debug_message(back); show_debug_message(id);" in instance creation code.

It's a string only in case of assets layer.

Eric Bunese

2017-07-18 15:54

Updater   ~0054310

Piotr, I am aware of that, but simply using the instance id does not solve my problem, I'd like to be able to retrieve the instance name from the room editor aswell.

Russell Kay

2017-07-21 22:21

Manager   ~0054472

Last edited: 2017-07-21 22:22

View 2 revisions

I am against this as in many games there are literally thousands of these and it hugely bloats the output files (we originally had just this) I really do not think it is a good idea, this is why we eventually had the ability to refer to the instance id so it could be referred to.

Now if you wanted the ability to use the id name as a string then that is different (C and C++ have this ability using the stringize operator #) so you could keep an array around of all the items you wanted to refer to..

i.e.

global.instance2name = ds_map_create();
globalinstance2name[? back ] = #back;


somethng like that? (I suspect it would not be the # operator as we would need to discuss it internally to work out what we think best fits)

Eric Bunese

2017-11-13 13:12

Updater   ~0056559

I think should cover it, Russel.