Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

GMRoomPack

Package GameMaker rooms and load them as you please · By YellowAfterlife

Load and place multiple rooms one after the other in succession?

A topic by _MHG_ created May 08, 2023 Views: 142 Replies: 2
Viewing posts 1 to 3

Hi,

Great asset, and works pretty well. I'd just like to ask how you'd approach the following:

Say I have 3 rooms - rm_start, rm_node_a, and rm_node_b. All three rooms have varying widths. The goal is to stitch them together, with rm_start as the "starting anchor", and then load the other two rooms in succession (order doesn't matter). So basically, it would look like the following:

[rm_start][rm_node_a][rm_node_b] 

OR

[rm_start][rm_node_b][rm_node_a] 

...again keeping in mind that they have varying widths. Right now, when I load the other two rooms, it places all of rm_node_a's instances directly on top of rm_node_b's instances (and vice versa). Here's my code:


var _x_ini_node = 2016;
    
    var json_rooms = scr_room_node(); // generated from rooms starting with rt_
    // pick a random room name from the map:
    var name = ds_map_find_first(json_rooms);
    repeat (irandom_range(0, ds_map_size(json_rooms) - 1)) {
        name = ds_map_find_next(json_rooms, name);
    }
    // and load that:
    room_pack_load_map(json_rooms[?name], _x_ini_node, 0, room_pack_flag_instances);
    // and when you're done:
    ds_map_destroy(json_rooms);


Could you recommend a way to get the rooms to load one after the other in succession with this extension?

Thanks!

Developer

Rooms are JSON - you can see what it has generated in the script/file and access it yourself as you may,

var _x_ini_node = 2016;
repeat (3) {
	var json_rooms = scr_room_node(); // generated from rooms starting with rt_
	// pick a random room name from the map:
	var name = ds_map_find_first(json_rooms);
	repeat (irandom_range(0, ds_map_size(json_rooms) - 1)) {
	    name = ds_map_find_next(json_rooms, name);
	}
	// and load that:
	var _room = json_rooms[?name];
	room_pack_load_map(_room, _x_ini_node, 0, room_pack_flag_instances);
	var _roomSettings = _room[?"roomSettings"];
	_x_ini_node += _roomSettings[?"Width"];
}
// and when you're done:
ds_map_destroy(json_rooms);

Ah, got it, thanks!