GMS 2 Saving and Loading JSON

Discussion in 'Programming' started by NNNIKKI, Jul 22, 2018.

  1. NNNIKKI

    NNNIKKI Member

    Joined:
    Apr 9, 2018
    Posts:
    40
    Whenever I startup my game, I get this error:
    Data structure with index does not exist.
    at gml_Script_load_game (line 21) - for (var a = 0; a < 36; a += 1;) global.lc[a] = levelslist[? a];

    That's funny, because in my save game code I have this:
    var levelslist = ds_list_create();
    for (var a = 0; a < 36; a += 1;) ds_list_add(levelslist,global.lc[a]);
    ds_map_add_list(mainmap,"Levels",levelslist);

    And I know for a fact that it saves properly.
    WHat's the problem? I'm not really experienced with JSON yet.
     
  2. NNNIKKI

    NNNIKKI Member

    Joined:
    Apr 9, 2018
    Posts:
    40
    The smileys are supposed to be ; )
     
  3. Paskaler

    Paskaler Member

    Joined:
    Jul 4, 2016
    Posts:
    315
    What I can spot is that levelslistis a ds_list and you are using the accessor meant for ds_maps in the error message:
    levelslist[? a] should be levelslist[| a]
     
  4. NNNIKKI

    NNNIKKI Member

    Joined:
    Apr 9, 2018
    Posts:
    40
    oh, i didn't know that
    i copied it from a vid where he used ds_maps
    Thanks for the help!
     

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