• 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 How to use the get_string_async correctly

X

xShadowsx

Guest
I have been trying to implement this function im my project however whenever I try to enter the correct string it never performs the right command. It always returns "Unable to breach firewall", can someone fix this code please

uskun = get_string_async("Breach Firewall with special password", "")
if uskun = "shadowlord"
{
global.uskunfire = 0;
suskun = 0;
show_message_async("Firewall Successfully Breached...");
}
else
{
show_message_async("Unable to breach firewall");
}
 

Stubbjax

Member
Are you using an asyncronous event to read the input? You'd also need to retrieve the string from the data map in the relevant async event.

The manual contains the information you need.
 
X

xShadowsx

Guest
All I want it to do is to perform a function when the word shadowlord is entered, I found a function known as get_string, however it said it was used for debugging purposes and instead use the followiing function get_string_async. Im quite a noob and dont know how i would go about applying to my situation since all that example does is store a username if thats what it is.

How would I add the map and assign it a string I want and how would I apply it to the if statement above.

Please I need help...
 

Stubbjax

Member
I don't see how, seeing as async_load is an inbuilt data structure that always exists (in the relevant async event).
 
X

xShadowsx

Guest
############################################################################################
ERROR in
action number 1
of Mouse Event for Left Button
for object Text:

Data structure with index does not exist.
at gml_Object_Text_LeftButtonDown_1 (line 2) - var i_d = ds_map_find_value(async_load, "id");
############################################################################################
 
X

xShadowsx

Guest
Dont you put the whole code together in one event. Like this
msg = get_string_async("What's your name?","Anon");
var i_d = ds_map_find_value(async_load, "id");
if i_d == msg
{
if ds_map_find_value(async_load, "status")
{
if ds_map_find_value(async_load, "result") != ""
{
global.Name = ds_map_find_value(async_load, "result");
}
}
}
Feels bad all I want is for my code to work. I understand bettter from examples..
 

Stubbjax

Member
No, you do not. You put the get_string_async in the event you want to call the message from, and the handling of the input in the relevant async event. Had you actually read this like I suggested earlier, which explains exactly where to put which code, you wouldn't have to keep asking the same questions.
 
X

xShadowsx

Guest
I am sorry I wasted your time stubbjax, up till now I did not know that the asynchronous Dialogs "EVENT" <======= had even existed and so I didnt know where to put the rest of the code.. So I am gonna go hit my head on a wall, thank you for your time and patience 0_0
 

Stubbjax

Member
Not a problem; glad I could help! My style of assistance is more geared towards pointing people in the right direction rather than spoonfeeding the answer (you'll learn better that way). :)
 
F

FeNniX

Guest
Not a problem; glad I could help! My style of assistance is more geared towards pointing people in the right direction rather than spoonfeeding the answer (you'll learn better that way). :)
Will you spoonfeed me? How should I retrieve variable as soon as user inputed something in get_string_async?
 

pfnredes

Member
Dejo la solución:
EVENTOS

Crear: La defino en blanco para que no de el evento Draw error en linea 1
global.Name = "";

LeftPressed: Presenta el valor
msg = get_string_async ("Introducir la IP", "127.0.0.1");

Diálogo: Recoje el valor de msg
var i_d = ds_map_find_value (async_load, "id");

si i_d == msg
{
si ds_map_find_value (async_load, "estado")
{
if ds_map_find_value (async_load, "resultado")! = ""
{
global.Name = ds_map_find_value (async_load, "resultado");
}
}
}

Dibujar: si queremos mostrar el valor en pantalla
dibujar_auto ();
draw_text (100,100, global.Name);

Ya está si se compila en Android funciona perfecto y en Windows también.
 
Top