Android Problem with get_integer_async function!

Ludiq

Member
Create event:
Pieces = get_integer_async("Products created?", "");

val = floor(Pieces/6);
val2 = frac(Pieces/6)*6;

Draw event:
draw_text(x,y,"Pieces per person " + string(val));
draw_text(x+20,y+20, "Pieces for redistribution " + string(val2));

The problem is for example when I input 3247 the program should say Pieces per person 541 and Pieces for redistribution 1 but its showing 0 and 0 for both values. The program was working fine with get_integer function but when I put it on my phone and ran it it said get_integer is deprecated and to change it to get_integer_async. I have done it but its not working. I have looked at the manual for it but I dont understand what I need to do. Can someone please help me?
 

GMWolf

aka fel666
I have done it but its not working. I have looked at the manual for it but I dont understand what I need to do. Can someone please help me?
The manual provides you with a code example, with the portion of code that goes in the async event.

What in particular about it do you not understand? It will be easier to help you if we know what part of the code you don't get.

Although I can already point you towards ds_maps, as you will need to understand them.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Create event:
Pieces = get_integer_async("Products created?", "");

val = floor(Pieces/6);
val2 = frac(Pieces/6)*6;
You are executing code that relies on the return value of an async function immediately after you fire it. You're giving the user no time to enter something. This is why you use Async events, because that fires after the user has entered something.
 

FrostyCat

Redemption Seeker
Read the Manual entry for get_integer_async and follow its instructions on using the Async - Dialog event. Send off the message first and remember its handle, catch the response in the Async event (always check async_load[? "id"] and async_load[? "status"]), and put up guards around code that depends on the response.

Create:
GML:
Pieces = undefined;
ih_Pieces = get_integer_async("Products created?", "");
Async - Dialog:
GML:
if (async_load[? "id"] == ih_Pieces) {
    if (async_load[? "status"]) {
        Pieces = async_load[? "value"];
    }
    ih_Pieces = undefined;
}
Draw:
GML:
if (!is_undefined(Pieces)) {
    draw_text(x, y, "Pieces per person " + string(Pieces div 6));
    draw_text(x+20, y+20, "Pieces for redistribution " + string(Pieces mod 6));
}
 
Top