Having problem with continue game after rerun the program

Discussion in 'Programming' started by krugen, Jul 21, 2019.

  1. krugen

    krugen Member

    Joined:
    Jan 24, 2019
    Posts:
    146
    I am having problem with save file. Before this, I could run the game, click new game, save game, exit game and continue game. I could still continue game if I close the program and run again provided I save my game before I close the program.

    Now, I can run new game, saved and continue, but not when I close and rerun again. The continue button is there but it says my ds_grid is not set before reading it.

    My new game code:

    Code:
    global.local_info_items = ds_grid_create(20, 3);
    var i, j;
    i = 0;
    j = 0;
    repeat (ds_grid_width(global.local_info_items))
       {
       repeat (ds_grid_height(global.local_info_items))
          {
          ds_grid_set(global.local_info_items, i, j, 0);
          j += 1;
          }
       j = 0;
       i += 1;
    }


    My save code

    Code:
    var dsw_local_info_items = ds_grid_write(global.local_info_items);
                    ds_map_replace(global.game_status, "k_local_info_items", dsw_local_info_items)


    My continue code:

    Code:
    var local_info_items_buffer = global.game_status[? "k_local_info_items"];
    ds_grid_read(global.local_info_items, local_info_items_buffer);

    Is there anything I'm missing?

    __________________________________________
    ############################################################################################
    FATAL ERROR in
    action number 1
    of Mouse Event for Left Pressed
    for object obj_continue:
    global variable name 'local_info_items' index (100034) not set before reading it.
    at gml_Object_obj_continue_Mouse_4 (line 63) - ds_grid_read(global.local_info_items, local_info_items_buffer);
    ############################################################################################
    --------------------------------------------------------------------------------------------
    stack frame is
    gml_Object_obj_continue_Mouse_4 (line 63)
     
  2. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    931
    If the "new game" code doesn't get run before you run the continue code, clearly your global.local_info_items variable will not be defined. If it does run before you run the continue game code, something else is messing with that variable.
     

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