kupo15
Member
Juju Adam's talk on JSON saving was amazing and Sean's breakdown tut of it really helped out for most of the saving you need to do in a game. How do we continue that and do more branches if we need to? Here is what I did by keeping the structure the same without branching. Is this okay or should I actually create another level for the grid instead of saving the grid_write string?
What I essentially have is a grid inside a grid. Each JSON treebranch saves the contents of the main grid, however column 2 contains the ID of another grid. I simply did a ds_write here and saved that string in the JSON but should I be branching this out and looping through that grid to save the values directly like how I did here?
If so how would I go about that? I feel like its essentially nesting a copy of the code above inside the above but am not sure how to go about that
Code:
var root_list = argument0;
// save every wishlist
var wishlist_size = ds_grid_height(wishlist_grid);
for(var i=0;i<wishlist_size;i++) // loop through every wishlist in the grid
{
var _map = ds_map_create();
ds_list_add(root_list,_map);
ds_list_mark_as_map(root_list,ds_list_size(root_list)-1);
// add wishlists
var _name = wishlist_grid[# 0,i]; // wishlist name
var _item_grid_str = ds_grid_write(wishlist_grid[# 1,i]); // id of item grid THIS VARIABLE
var _owner = wishlist_grid[# 2,i]; // owner id
var _date = wishlist_grid[# 3,i]; // event date
var _unique_id = wishlist_grid[# 4,i]; // unique id
var _private = wishlist_grid[# 5,i]; // private
ds_map_add(_map,"name",_name); // save wishlist name
ds_map_add(_map,"itemlist",_item_grid_str); // save ids of item lists THIS VARIABLE
ds_map_add(_map,"owner",_owner); // save owner id of list
ds_map_add(_map,"date",_date); // save event date
ds_map_add(_map,"unique_id",_unique_id); // save unique list id (-1 custom or preset id)
ds_map_add(_map,"private",_private); // save private or not
}
If so how would I go about that? I feel like its essentially nesting a copy of the code above inside the above but am not sure how to go about that