A note on room casing


If your room names do not match their file names (e.g. rm_some’s file/directory are called rm_Some) for some reason, the keys in GMRoomPack maps might also not match the room names.

Here’s a script that you can run after creating the map to fix up the names:

function room_pack_fix_casing(_room_map) {
	//
	var _room_ids = asset_get_ids(asset_room);
	var _room_fixes = ds_map_create();
	for (var i = 0, n = array_length(_room_ids); i < n; i++) {
		var _room_name = room_get_name(_room_ids[i]);
		_room_fixes[?string_lower(_room_name)] = _room_name;
	}
	//
	var _keys = ds_map_keys_to_array(_room_map);
	for (var i = 0, n = array_length(_keys); i < n; i++) {
		var _key = _keys[i];
		var _key_fixed = _room_fixes[?string_lower(_key)];
		if (_key_fixed != undefined && _key_fixed != _key) {
			_room_map[?_key_fixed] = _room_map[?_key];
			ds_map_delete(_room_map, _key);
		}
	}
	//
	ds_map_destroy(_room_fixes);
}

Used like so

var json_rooms = scr_rts(); // generated from rooms starting with rt_
json_rooms = room_pack_fix_casing(json_rooms);

Get GMRoomPack

Buy Now$4.95 USD or more

Leave a comment

Log in with itch.io to leave a comment.