Using this function you can retrieve the index value of the tile set resource assigned to a given tilemap element on a layer. You give the tilemap element ID (which you get when you create a tilemap element using layer_tilemap_create() or when you use the function layer_tilemap_get_id()), and the function will return the tile set index value.
tilemap_get_tileset(tilemap_element_id);
参数 描述 tilemap_element_id The unique ID value of the tilemap element to get the tile set from
Tile Set index value (Real)
var lay_id = layer_get_id("Tiles_trees");
var map_id = layer_tilemap_get_id(lay_id);
if tilemap_get_tileset(map_id) != ts_Nighttime
{
tilemap_tileset(map_id, ts_Nighttime);
}
The above code checks the current tile set assigned to the layer "Tiles_trees" and if it is not "ts_Nighttime" then that tile set is assigned to the tilemap.