Legacy GM Help with a text input

Psycho_666

Member
Hey.
It's probably really simple, but I can't for the life of me make it work.
I am following this video tutorial:
It is fine, but I can't make the dot, coma, question mark, etc characters show up.
I tried adding them in the enabled characters list - not working. Tried chr(code) - not working. I don't know what to do with it.

I tried removing the whole enabled characters list thing from the program, but it somehow breaks absolutely everything and I can't find out what am I doing wrong.
 

Psycho_666

Member
GML:
if(string_count(chr(keyboard_key),enabled_keys))and(string_length(chr(keyboard_key))==1)
    {
        blink=true;//setting up custom cursor blink
        alarm[0]=blink_speed;
        switch(keyboard_lastchar)
            {
            case "#": text+="\#"; break;
            default: text+=keyboard_lastchar; break;
            }
    }

if !keyboard_check(vk_control)
    {
    switch(keyboard_key)
        {
        case vk_enter: text+="#"; break;
        case vk_backspace: switch(string_char_at(text,string_length(text)))
            {
            case "#": text=string_copy(text,0,string_length(text)-2); break;
            default: text=string_copy(text,0,string_length(text)-1); break;
            }
        default: break;
        }
    }
else
    {
    switch(keyboard_key)
        {
        case ord("V"): text+=clipboard_get_text();break;
        default: break;
        }
    }
That is the code from the tutorial. I tried adding some checks in the enter and backspace switch statement, but I can't make it recognize me pressing the , key...
 
P

ParodyKnaveBob

Guest
"What does it do instead of what you expect?" is a standard troubleshooting question, but I can't help but ask this standard GameMaker question: Did you add the characters to your font resource? (I don't know if that's what you meant by the "enabled characters list" since it's someone else's half hour tutorial, although it looks like you mean the coded list at 5 minutes in.)
 

Psycho_666

Member
Enabled characters are literally a string of letters and numbers with the space Inbetween them. The idea is to limit the ability of the user to add all sorts of crap. I want the user to be able to insert only the basics.
I tried to add ".,?-" to the string of enabled characters. No effect. I still can't use them.
GML:
enabled_keys="ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890”;
That's in the create event.

I tried removing it from the program but for some reason it messes up with the rest of the program...
 

TsukaYuriko

☄️
Forum Staff
Moderator
No, what you've done is merely unrelated to what you were trying to do at this moment. Keep in mind that you can use the experience you gained from it to help you both now when doing things a different way as well as in the future when you are trying to do the thing you just did... and then start from scratch. ;)
 

Psycho_666

Member
you can use the experience you gained from it to help you both now when doing things a different way as well as in the future when you are trying to do the thing you just did... and then start from scratch. ;)
That's how I learned most of what I know - do a tutorial, adapt it to the goal I want to achieve, then do something else...
 

Psycho_666

Member
keyboard_string doesn't quite do what I want it to do. Enter doesn't start a new line...
My program is a mess...
I will start from scratch tomorrow.
 
Top