• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [Solved]Need help resetting variable storing keyboard_string.

H

Halix

Guest
Code:
///create
text = " ";                   

///Step
text = keyboard_string;
if(keyboard_check_pressed(vk_enter))
{
   text = " ";
}

///Draw

draw_text(x+10,y-10,text);
Noob programmer here. I am trying to draw the typed out text onto the screen and then remove it when I press enter, but the text seems to disappear and then almost instantly reappear, and anything else I type just adds to the characters. What am I doing wrong here?
 

cdgamedev

Member
You didn't reset the keyboard_string, rather the text variable... Using the keyboard_string instead removes the need for text
Code:
/// Step
if(keyboard_check_pressed(vk_enter))
    {
    keyboard_string = "";
    }

/// Draw
draw_text(x+10,y-10,keyboard_string);
 
W

Wraithious

Guest
You can also use io_clear for this
Code:
///Step
text = keyboard_string;
if(keyboard_check_pressed(vk_enter))
{
   io_clear();//Edited
   text = " ";
}
 
Last edited by a moderator:
Top