Legacy GM Get_String Custom Help

Gamerev147

Member
How can I make something exactly like the get_string function, but have it custom?

I need my game to stay in full screen, but I when loading a map, the easiest way to get the file name for the map is by using get_string.

I've know how to make what the player types show up in a box and what not. But I need it to be easy to implement and also exactly like the get_string function.

Any help is appreciated. Thanks! :)
 

CloseRange

Member
I could be wrong on what your asking but I think the easiest way is just use keyboard_string.
that's a built in variable that stores the last key strokes you pressed, it even works with backspaces.

before you get to the screen where you have the player typing just say:
Code:
keyboard_string  = "";
and that will reset it so nothing else they typed before will be used.

It's already a varable so you can just use that in your code and then also use:
Code:
draw_text(x, y, keyboard_string);
to draw in anywhere

Hope this helped!
-CloseRange
 

Gamerev147

Member
I could be wrong on what your asking but I think the easiest way is just use keyboard_string.
that's a built in variable that stores the last key strokes you pressed, it even works with backspaces.

before you get to the screen where you have the player typing just say:
Code:
keyboard_string  = "";
and that will reset it so nothing else they typed before will be used.

It's already a varable so you can just use that in your code and then also use:
Code:
draw_text(x, y, keyboard_string);
to draw in anywhere

Hope this helped!
-CloseRange
Yes, but I need it so when the user pressed the "Enter" key, the string is executed in a script. I tried just adding a simple "enter" statement after what you said, but it doesn't work.
 

CloseRange

Member
it would be easier if i saw some code to see what you meant. if you want it to be executed in a script just use keyboard_string in the input:
Code:
/// execute script
if (keyboard_check_pressed(vk_enter)) {
     my_script(keyboard_string);
}
 

Gamerev147

Member
it would be easier if i saw some code to see what you meant. if you want it to be executed in a script just use keyboard_string in the input:
Code:
/// execute script
if (keyboard_check_pressed(vk_enter)) {
     my_script(keyboard_string);
}
I removed all the code I tried because it didn't work.
Apparently this is harder to explain than I thought... I just need an exact replication of the get_string function.
 
L

LittleRobotGames

Guest
I do the same thing in a game i'm working on. There's lots of prompts that require user input that doesn't impact fullscreen. Here's how it works:

Basically, when an account is selected to be logged into, it creates obj_password and sets "password" to the password that that account requires. Then, in the create event, you'll want something like this: (Of course, it's modified to fit your needs)

Code:
keyboard_string="";
text="";
cursor="|";
can_write=true;
Then, in the step event, add this:

Code:
if position_meeting(mouse_x,mouse_y,self)
    {
    if mouse_check_button_pressed(mb_left)
        {
        can_write=true;
        keyboard_string=text;
        }
    }
if can_write=true
    {
    cursor="|";
    text=string_copy(keyboard_string,1,16);
    if keyboard_check_pressed(vk_enter)
        {
        can_write=false;
        keyboard_string="";
        alarm[0]=2;
        }
    }
else
    {
    cursor="";
    }
Alarm 0 event is whatever happens after pressing enter. In your case, it would load a room using the "text" variable. Now, what's up to you is how to display this information, just at some point include:

Code:
if can_write=true
    {
    draw_text(x,y-7,text+cursor);
    }
else
    {
    draw_text(x,y-7,text);
    }
This just draw's your text. The whole "cursor" variable stuff is also completely up to you. Good luck to you sir.
 

Gamerev147

Member
I do the same thing in a game i'm working on. There's lots of prompts that require user input that doesn't impact fullscreen. Here's how it works:

Basically, when an account is selected to be logged into, it creates obj_password and sets "password" to the password that that account requires. Then, in the create event, you'll want something like this: (Of course, it's modified to fit your needs)

Code:
keyboard_string="";
text="";
cursor="|";
can_write=true;
Then, in the step event, add this:

Code:
if position_meeting(mouse_x,mouse_y,self)
    {
    if mouse_check_button_pressed(mb_left)
        {
        can_write=true;
        keyboard_string=text;
        }
    }
if can_write=true
    {
    cursor="|";
    text=string_copy(keyboard_string,1,16);
    if keyboard_check_pressed(vk_enter)
        {
        can_write=false;
        keyboard_string="";
        alarm[0]=2;
        }
    }
else
    {
    cursor="";
    }
Alarm 0 event is whatever happens after pressing enter. In your case, it would load a room using the "text" variable. Now, what's up to you is how to display this information, just at some point include:

Code:
if can_write=true
    {
    draw_text(x,y-7,text+cursor);
    }
else
    {
    draw_text(x,y-7,text);
    }
This just draw's your text. The whole "cursor" variable stuff is also completely up to you. Good luck to you sir.
Awesome! Wow thank you!
This code is very easy to understand and implement. Thank you so much!
 
Top