Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

GMRoomPack

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

Error while loading external JSON room

A topic by kgm created 98 days ago Views: 57 Replies: 1
Viewing posts 1 to 2
(5 edits)

I got this error while loading a JSON room from include file:


___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of  Step Event0
for object o_map_external:

layer_set_visible argument 2 incorrect type (undefined) expecting a Number (YYGB)
 at gml_Script_room_pack_raw_add_layer (line 87) -                             layer_set_visible(l_rl,l_ql[?"visible"]);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_room_pack_raw_add_layer (line 87)
called from - gml_Script_room_pack_raw_run_impl2 (line 13) -        room_pack_raw_add_layer(l_lrs[|l_lrk]);
called from - gml_Script_room_pack_load_map (line 18) - room_pack_raw_run_impl2(l_map);
called from - gml_Object_o_map_external_Step_0 (line 17) -               room_pack_load_map(json_rooms[?map_name], x, y, flags);


The room was store in a file which contain multiple rooms. The flags was: room_pack_flag_instances | room_pack_flag_sprites | room_pack_flag_tiles. Also sometimes this same room can be loaded successfully without errors on a different room in my game.

Here's the code I used to load the room:


        // Parse file to json        
        var json = json_decode(s);
        // Load map info
        var room_prefab = json[?map_name];
        var room_settings = room_prefab[?"roomSettings"];
        var room_h= room_settings[?"Height"];
        // Get the map
        room_pack_load_map(room_prefab, x, y - room_h, flags);
        ds_map_destroy(json);

Developer (1 edit)

I just uploaded a fix for that - IIRC that was when you had layers that are initially invisible, and the server would omit the property in JSON to save space, but then the extension didn't check if it's "undefined" rather than true/false