1
\$\begingroup\$

As stated in the title, they get the following error:

 ############################################################################################ FATAL ERROR in action number 1 of Other Event: Game Start for object obj_music_controller: ds_map_find_value argument 1 incorrect type (undefined) expecting a Number (YYGI32) at gml_Script_scr_checkLastLoggedInJson ############################################################################################ -------------------------------------------------------------------------------------------- stack frame is gml_Script_scr_checkLastLoggedInJson (line -1) gml_Object_obj_music_controller_Other_2 

The function ds_map_find_value() is not being called in the script scr_checkLastLoggedInJson(). (Even if it was, how could it be happening at line -1?)

Nor is it called in the Game Start event of the obj_music_controller object. I also checked every use of ds_map_find_value() in the entire game and they are all fine.

Furthermore, this is only happening with 1 person. And they have tried uninstalling it and re-downloading. Even after i uploaded a new version of the game, this still happened to them and only them.

EDIT: scr_checkLastLoggedInJson()


var result = false; if (file_exists("saveJson.json")) { var saveJson = scr_loadJSONFromFile("saveJson.json");//ds_map var saveJsonNames = saveJson[? "Names"]; //ds_list var userSaveData = noone; var saveJsonSaves = noone; if (ds_list_size(saveJsonNames) == 1) //If there is only 1 user, that is the one to load. { result = true; var username = saveJsonNames[| 0]; global.username = username; } else { //Find the user who was last logged in and assign them to global.username. for (var i = 0; i < ds_list_size(saveJsonNames); i++) { var username = saveJsonNames[| i]; saveJsonSaves = saveJson[? "Saves"];//ds_map if (!is_undefined(username)) { userSaveData = saveJsonSaves[? username]; //ds_map if (userSaveData[? "Last Logged In"]) { result = true; global.username = username; ds_map_destroy(userSaveData); ds_map_destroy(saveJsonSaves); break; } } } } if (ds_exists(userSaveData, ds_type_map)) { ds_map_destroy(userSaveData); } if (ds_exists(saveJsonSaves, ds_type_map)) { ds_map_destroy(saveJsonSaves); } ds_list_destroy(saveJsonNames); ds_map_destroy(saveJson); } return result; 

\$\endgroup\$
6
  • 2
    \$\begingroup\$ Can you show us the code for gml_Script_scr_checkLastLoggedInJson ? Even though you don't call this method directly, it might get called as a consequence of something else you're doing. \$\endgroup\$ Commented Feb 27, 2020 at 14:22
  • 1
    \$\begingroup\$ ds_map_find_value is called anytime you reference saveJason[? "Some string here"], because you're finding the value associated with that input string. In some case it's undefined. It might be where you find a username, then look up a save with that name? \$\endgroup\$ Commented Feb 28, 2020 at 2:55
  • \$\begingroup\$ Hmmm, ok I will add code to look out for this and see what happens. \$\endgroup\$ Commented Feb 28, 2020 at 2:59
  • \$\begingroup\$ I did a game-wide search for [? and identified all places where I used this accessor with a variable (like [? username] in the example above). I then enclosed it and all code related to it in an if with a condition like !is_undefined(username). But this didn't fix the problem. \$\endgroup\$ Commented Feb 28, 2020 at 14:02
  • \$\begingroup\$ Actually, maybe ds_map_find_value argument 1 incorrect type (undefined) expecting a Number (YYGI32) is referring to the ds_map argument of ds_map_find_value(ds_map, value). Because i know GMS starts indexing at 1 instead of 0 for some things and maybe this is one of those things. Furthermore, the ds_map argument would have to always be a number because it is the ID of a ds_map, whereas the second argument can be a string so I will look for places in the code where the map being searched doesnt actually exist. \$\endgroup\$ Commented Feb 28, 2020 at 14:46

1 Answer 1

2
\$\begingroup\$

I fixed it. Idk what caused this, but here we go. My save file is structured like this: {"Names":[], "Saves":{}}. Somehow the "Saves" key wasnt created (only in the case of this specific person) so at some point in the code it does saveJsonSaves = saveJson[? "Saves"] and then saveJsonSaves is undefined. So i added code to catch this scenario and reconstruct the missing "Saves" key.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.