GMS 2 Way to store ds_grids within other data structures?

DerFubel

Member
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.
 

GMWolf

aka fel666
How are you trying to save it?
Could we have some code to help understand where the issue is coming from?
 

kraifpatrik

Member
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.
and then stored this array (actually the pointer to this array) in the ds_grid
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.
 
Top