J
JapanGamer29
Guest
Hey guys. I'm baffled by this problem:
When I run my game, a json file for language (menu items, etc.) is opened and read into a ds_map in the Create event of my persistent objGameController object.
It all works fine. The game is finished and already available on Steam... but...
... when I try to run the game in the Debugger, it can't find the language data and throws an error:
Let me show you an example of the top of this json file:
As I said, that file works fine outside of the Debugger.
Here's how I get that data:
Here's the scrReadJSON script:
And then I can access the map with this:
scrLang looks like this:
So that's all the code. As I say, if I just run the game normally, the language file is read in and the map works fine. But when I use the Debugger, it's unable to find the "langPage" index in global.langMap.
Any ideas why? Thank you.
When I run my game, a json file for language (menu items, etc.) is opened and read into a ds_map in the Create event of my persistent objGameController object.
It all works fine. The game is finished and already available on Steam... but...
... when I try to run the game in the Debugger, it can't find the language data and throws an error:
Code:
############################################################################################
ERROR in
action number 1
of Create Event
for object obj_menu:
Data structure with index does not exist.
at gml_Script_scrLang (line 16) - if (!is_undefined(ds_map_find_value(langPage, key)))
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scrLang (line 16)
called from - gml_Object_obj_menu_Create_0 (line 6) - menu[0] = scrLang(pg, "start"); // "START";
Code:
{
"menu": [
{
"start": "START",
.... snip ....
}
... snip ...
]
}
Here's how I get that data:
Code:
// load language file
global.langMap = scrReadJSON("lang_eng.json");
Code:
fileName = argument0;
var data = "";
var json = file_text_open_read(working_directory + fileName);
while(!file_text_eof(json))
{
data += file_text_read_string(json);
file_text_readln(json);
}
file_text_close(json);
var resultMap = json_decode(data);
//show_debug_message("langMap: " + data);
return resultMap;
Code:
pg = "menu";
menu[0] = scrLang(pg, "start");
Code:
var page = argument[0];
var key = argument[1];
var text = "";
if (ds_exists(global.langMap, ds_type_map))
{
var langPage = ds_map_find_value(global.langMap, page);
// if (ds_exists(langPage, ds_type_map))
// {
if (!is_undefined(ds_map_find_value(langPage, key))) // ERROR THROWN HERE
{
text = ds_map_find_value(langPage, key);
}
// }
}
return text;
Any ideas why? Thank you.
Last edited: