When you call this function you are telling GameMaker Studio 2 that all further layer functions should be applied to the given room. In this way you can procedurally change or generate layers and layer contents in a room that is not the current room. When you are finished adding layers or layer elements to a room, call the function layer_reset_target_room to reset the room target (or call this function again with a room argument of -1).
|room||The room to target for all further layer functions|
var l = layer_get_id("SpriteAssets");
layer_sprite_create(l, random(room_get_width(rm_Game)), random(room_get_height(rm_Game)), spr_Trees);
The above code sets the target room to the room "rm_Game" and then gets the layer ID for the layer called "SpriteAssets" in that room. This layer ID is then used to add 50 random sprite assets to the layer, before the layer target is reset to the current room.