GMS 2 Way to store ds_grids within other data structures?

Discussion in 'Programming' started by DerFubel, Oct 10, 2019.

  1. DerFubel

    DerFubel Member

    Oct 10, 2019
    I'm currently working on a game which uses different maps (not ds_maps, just maps!). Therefore I saved all the tiles of a map in a ds_grid. So I end up with many different ds_grids, that I want to save & load. Is there any way to do this with data structures? I already tried to put them in other ds_grids and ds_lists, but the game won't let me load it, I'll always get the "trying to index a variable which is not an array" error.

    Or does it work and I simply overlooked something? I'm pretty sure that I always treated the ds_grid as a ds_grid.

    I've created an array for each tile to store sprite and z-position and then stored this array (actually the pointer to this array) in the ds_grid. Is it possible that something went wrong there? I'm really on the hook because I don't know what I did wrong. Thanks in advance.
  2. GMWolf

    GMWolf aka fel666

    Jun 21, 2016
    How are you trying to save it?
    Could we have some code to help understand where the issue is coming from?
  3. kraifpatrik

    kraifpatrik Member

    Jun 23, 2016
    I'm not sure how ds_grid_write handles storing grids which contain arrays but part of your question could be a clue why what you're doing doesn't work.
    If the grid cell contains a pointer, which is a number, and you save it and load it back, you will get a number, not an array. That would be why are you getting the "trying to index a variable which is not an array" error. I would suggest you having a look into buffers to create your own ways how to store and load back data.

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