Legacy GM DS Map Issue

J

JDSTIGER

Guest
I have no Idea why anything score related doesn't work for me..
ERROR:
Code:
of Draw Event
for object obj_drawscorehsmenu:


global variable <unknown built-in variable>(-1610512728, -2147483648) not set before reading it.
 at gml_Object_obj_drawscorehsmenu_DrawEvent_4 (line 1) - action_draw_variable( global.HighScore, room_width / 2, 520 );



GAME END:
Code:
global.HighScore = global.HighScore;
global.SettingsMap[? "HighScore"] = global.HighScore
ds_map_secure_save(global.SettingsMap, "myappdata");
EXECUTE ON GAME LAUNCH:
Code:
if file_exists("myappdata") then {
    // Load user settings from file
    global.SettingsMap = ds_map_secure_load("myappdata");

    // Get saved high score
    global.HighScore = global.SettingsMap[? "HighScore"];

    // Set up new user settings file
    global.SettingsMap = ds_map_create();

    // Set high score to zero
    global.HighScore = 0;
    global.SettingsMap[? "HighScore"] = global.HighScore;

    // Save the ds_map with all our user info to a file
    ds_map_secure_save(global.SettingsMap, "myappdata");
}

EDIT: FIXED THE ERROR BUT HIGHSCORE DOES NOT UPDATE
Code:
if (global.Highscore < score)
global.HighScore = score;
global.SettingsMap[? "HighScore"] = global.HighScore
ds_map_secure_save(global.SettingsMap, "myappdata");

 
Last edited by a moderator:

Yal

šŸ§ *penguin noises*
GMC Elder
global variable <unknown built-in variable>(-1610512728, -2147483648) not set before reading it.
The cause seems pretty clear to me :p Just make sure the variable is initialized before you try to draw it (note that Game Start and Room Start events are run AFTER the Create event)
 
J

JDSTIGER

Guest
Your 'myappdata' file doesn't (necessarily) initially exist. If it doesn't exist yet, your global.HighScore won't be initialised, giving you this error.
So what's the fix, lol.
Are you initializing the variables in game start event even if the file doesn't exist?
Got it I forgot the 'else'

But now the Highscore doesnt actually update it stays at 0
 
J

JDSTIGER

Guest
Just to make sure we are on the same page. The error is gone but the high score doesn't update? Or still the error message which crashes the game?
The score does not update I think I need a code that says if the score is greater but I don't recall what it is.
 
J

JDSTIGER

Guest
The score does not update I think I need a code that says if the score is greater but I don't recall what it is.
I got the code but It does not work please see 1st post for more info!
 
Top