Search code examples
game-maker

Is it possible to get the user input to only accept certain words and then activate a script that was dormant until then? [Game-Maker]


I was wondering if in game-maker, if it is possible to make it so that when the user let's say clicks for the first time(which is assigned to attack at the moment) a popup appears asking for user input and then they have to type in a certain word/sentence, and then when they get it right the popup disappears and then they have unlocked the ability to attack? Thanks!


Solution

  • In your room controller object,

    1 - have a "create" step wich initialize your "firstLeftClick" to "true"

    2 - have a "step" event in which you have a "execute code " :

    // code to execute
    posX = (room_height - sprite_get_height(myDialogObject))/2;
    posY = (room_width - sprite_get_width(myDialogObject))/2;
    
    if(firstLeftClick && mouse_check_button(mb_left)){
        instance_create(posX,posY,myDialogObject);
    }
    

    Next have your dialog object (dont know how to create but must'nt be hard and the same way add a step event that verify the value of the prompt and do something when some patterns are recognised.

    See script_execute(scr, arg0, arg1, arg2, ...); at https://docs.yoyogames.com/index.html?page=source%2Fdadiospice%2F002_reference%2Fmouse,%20keyboard%20and%20other%20controls%2Fdevice%20input%2Findex.html