layer_get_name

This function gets the name of the given layer.

You supply the unique layer ID value and if the layer is one of the named layers created in The Room Editor, then the function will return a string with the layer name. If the layer is not one of the Room Editor ones (i.e.: it was created using layer_create) then an empty string "" will be returned.

 

Syntax:

layer_get_name(layer_id)

Argument Type Description
layer_id Layer The unique ID value of the layer to get the name of

 

Returns:

String

 

Example:

var _arr_layers = layer_get_all();
var _arr_layers_named = [];
for (var i = 0; i < array_length(_arr_layers); i++)
{
    if (layer_get_name(_arr_layers[i]) != "")
    {
        array_push(_arr_layers_named, _arr_layers[i]);
    }
}

The above code gets the IDs of all the layers in the room and then loops through them to see if they're named layers. If they are they are then their ID is added to a list.