Search code examples
gmlgame-maker-studio-2

Game Maker Studio 2 get_string deprecated


I am trying to ask the user for a name to put into my highscore table.

I do not want to use get_string_async because then it adds a the name and score before the user has even given a name, however get_string does not work because it is deprecated.

name = get_string("Game Over. What is your name?","Player");
highscore_add(name,score);
global.highscore == 1; //tells draw event to draw highscore table.

Is there an alternative to get_string that waits for input before continuing through the code?


Solution

  • If you want the player to type in their own name, try setting something up where, when you first start typing it does

    you can put this into a script, and say:

    name = scr_get_name();
    
    
    //Inside of "scr_get_name()"
    keyboard_string = 0;
    if(player_typing){
        if(keyboard_check_pressed(vk_enter)){
            name = keyboard_string;
            return(name);
        }
    }