Layer Name Filtering β
When loading full rooms with RoomLoader.Load() or using Screenshotting methods, you may want to filter target room layers by name, so that only layers with the specified names are loaded/screenshotted.
This section explains how to achieve this using Whitelisting and Blacklisting.
- Both filters are fully user-managed and do not reset automatically after loading.
- Both filters have their own sets of methods and can be used independently or together. You can also combine them with Asset Type Filtering in any configuration.
- Blacklist takes precedence over Whitelist - layers included in both filters are ignored.
WARNING
Just like everywhere else in GameMaker, layer names are case-sensitive and must match the room editor layer names exactly.
// Whitelists "Trees", "Rocks" and "Grass" layers, only those will be loaded:
RoomLoader.LayerWhitelistAdd("Trees", "Rocks", "Grass");
// Blacklists the "Rocks" layer. Now only "Trees" and "Grass" will be loaded:
RoomLoader.LayerBlacklistAdd("Rocks");
payload = RoomLoader.Load(rmForest, x, y);
// Reset both filters:
RoomLoader.LayerWhitelistReset().LayerBlacklistReset();
Whitelist β
When Whitelist contains entries, only the layers with whitelisted names are loaded. Other layers are ignored.
.LayerWhitelistAdd()
β
RoomLoader.LayerWhitelistAdd(...layerNames)
β Struct.RoomLoader
Adds all given layer names to the Whitelist layer filter.
Parameter | Type | Description |
---|---|---|
...layerNames | String | The layer names to whitelist, supports any amount of arguments |
// Whitelists the "Buildings" layer name:
RoomLoader.LayerWhitelistAdd("Buildings");
// Whitelists the "Trees" and "Rocks" layer names:
RoomLoader.LayerWhitelistAdd("Trees", "Rocks");
.LayerWhitelistRemove()
β
RoomLoader.LayerWhitelistRemove(...layerNames)
β Struct.RoomLoader
Removes all given layer names from the Whitelist layer filter.
Parameter | Type | Description |
---|---|---|
...layerNames | String | The layer names to remove from the whitelist, supports any amount of arguments |
// Removes the "Buildings" layer name from Whitelist:
RoomLoader.LayerWhitelistRemove("Buildings");
// Removes "Trees" and "Rocks" layer names from Whitelist:
RoomLoader.LayerWhitelistRemove("Trees", "Rocks");
.LayerWhitelistSet()
β
RoomLoader.LayerWhitelistSet(layerNames)
β Struct.RoomLoader
Sets the Whitelist layer filter to the given array of layer names.
Parameter | Type | Description |
---|---|---|
layerNames | Array of String | An array of layer names to whitelist |
// Whitelists "Bushes", "Trees" and "Flowers" array from the _whitelist array:
var _whitelist = ["Bushes", "Trees", "Flowers"];
RoomLoader.LayerWhitelistSet(_whitelist);
.LayerWhitelistReset()
β
RoomLoader.LayerWhitelistReset()
β Struct.RoomLoader
Resets the Whitelist layer filter by removing all names from it.
RoomLoader.LayerWhitelistReset(); // Resets the Whitelist.
.LayerWhitelistGet()
β
Returns an array of whitelisted layer names.
// Gets an array of whitelisted layer names, blacklists them and resets Whitelist:
array_foreach(RoomLoader.LayerWhitelistGet(), function(_layerName) {
RoomLoader.LayerBlacklistAdd(_layerName);
});
RoomLoader.LayerWhitelistReset();
Blacklist β
When Blacklist contains entries, layers with blacklisted names are ignored. Other layers are loaded.
.LayerBlacklistAdd()
β
RoomLoader.LayerBlacklistAdd(...layerNames)
β Struct.RoomLoader
Adds all given layer names to the Blacklist layer filter.
Parameter | Type | Description |
---|---|---|
...layerNames | String | The layer names to blacklist, supports any amount of arguments |
// Blacklists the "Buildings" layer name:
RoomLoader.LayerBlacklistAdd("Buildings");
// Blacklists the "Trees" and "Rocks" layer names:
RoomLoader.LayerBlacklistAdd("Trees", "Rocks");
.LayerBlacklistRemove()
β
RoomLoader.LayerBlacklistRemove(...layerNames)
β Struct.RoomLoader
Removes all given layer names from the Blacklist layer filter.
// Removes the "Buildings" layer name from Blacklist:
RoomLoader.LayerBlacklistRemove("Buildings");
// Removes "Trees" and "Rocks" layer names from Blacklist:
RoomLoader.LayerBlacklistRemove("Trees", "Rocks");
.LayerBlacklistSet()
β
RoomLoader.LayerBlacklistSet(layerNames)
β Struct.RoomLoader
Sets the Blacklist layer filter to the given array of layer names.
Parameter | Type | Description |
---|---|---|
layerNames | Array of String | An array of layer names to blacklist |
// Blacklists "Bushes", "Trees" and "Flowers" array from the _blacklist array:
var _blacklist = ["Bushes", "Trees", "Flowers"];
RoomLoader.LayerBlacklistSet(_blacklist);
.LayerBlacklistReset()
β
RoomLoader.LayerBlacklistReset()
β Struct.RoomLoader
Resets the Blacklist layer filter by removing all previously added layer names.
RoomLoader.LayerBlacklistReset(); // Resets the Blacklist.
.LayerBlacklistGet()
β
Returns an array of blacklisted layer names.
// Gets an array of blacklisted layer names, whitelists them and resets Blacklist:
array_foreach(RoomLoader.LayerBlacklistGet(), function(_layerName) {
RoomLoader.LayerWhitelistAdd(_layerName);
});
RoomLoader.LayerBlacklistReset();