GM:S 1.4 Opposite of ds_map_add_map() ?

Discussion in 'Programming' started by AlekM, Jul 1, 2018.

Tags:
  1. AlekM

    AlekM Guest

    Hello!

    I have various ds_map's which I stuffed into one main ds_map to encode into a json file. However, I can't figure out how to copy a nested ds_map out of the ds_map it is nested in.

    Is there any way to undo the ds_map_add_map() function?

    Thanks,
    Alek
     
  2. Paskaler

    Paskaler Member

    Joined:
    Jul 4, 2016
    Posts:
    315
    You need to get a reference to the added map first, using the key you passed by adding it and then call ds_map_destroy with the value returned and finally set the value at that key to noone(or anything less tham zero, as zero and up is a valid ID for a ds structure)

    Code:
    var added_map = parent_map[?the_key];
    ds_map_destroy(added_map);
    parent_map[?the_key] = noone;
    
    Do note that GM treats maps that are added by the function you used in a special way and it's meant for JSON encoding the maps, and I not sure if doing what I described above can lead to errors. If you don't need JSON functionality add maps using ds_map_add or the accessor.
     
    AlekM likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice