• 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 Async dialog event confusion

marasovec

Member
So, I have 2 objects in a room. The first one is for changing nickname an the second one is for changing level name. I use a global variable "global.nick_async" for the nickname changing object and a normal variable "lvl_name" for the level changing object.
But when I click on the nickname changing object it sometimes activates the level name changing async event and when I click on the level name changing object it sometimes also activates the nickname changing async event.

nickname changing object:
Code:
MOUSE CLICK EVENT
if position_meeting(mouse_x, mouse_y, id) global.nick_async = get_string_async("nickname", "");

ASYNC EVENT
if ds_map_find_value(async_load, "id") == global.nick_async
    {
    if ds_map_find_value(async_load, "result") != ""
       {
       global.nickname = ds_map_find_value(async_load, "result");
       scr_settings_save();
       }
   }
level name changing object:
Code:
CREATE EVENT
lvl_name = undefined;

MOUSE CLICK EVENT
if position_meeting(mouse_x, mouse_y, id) lvl_name = get_string_async("level name", "");

ASYNC EVENT
if ds_map_find_value(async_load, "id") == lvl_name
    {
    if ds_map_find_value(async_load, "result") != ""
       {
       global.filename = ds_map_find_value(async_load, "result");
       room_goto(...);
       }
   }
 
Last edited:

FrostyCat

Redemption Seeker
You should set the asynchronous handles back to -1 after handling them. The GMS 2 runner internally reuses IDs, so there's a chance that one would get the first 0 and the other one would get a reused 0 after the first one is done with it, for example.
 
Top