Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Tilemap ids lost/disconnected from layers on reload [Solved]

A topic by SaraJS created Jun 16, 2022 Views: 204
Viewing posts 1 to 1
(1 edit)

When reloading a room it seems that it is no longer possible to get the tilemap id of a given layer. Are these perhaps being moved/consolidated/disconnected from their layers somehow?

I can still get layers by name but when looking for the tilemap associated with that layer I get -1 from layer_tilemap_get_id().

Edit: nevermind! I found the older topic mentioning this. For anyone else, because the layers are recreated dynamically by gmlive you cannot access their tilemap ids using tilemap_get_id(). YAL suggested the following script as a fix:

/// layer_tilemap_get_id_fixed(layer) 
var els = layer_get_all_elements(argument0); 
var n = array_length_1d(els); 
for (var i = 0; i < n; i++) 
{     
    var el = els[i];     
    if (layer_get_element_type(el) == layerelementtype_tilemap) 
    {         
        return el;
    }
} return -1;