Guest User

Untitled

a guest
Dec 16th, 2019
762
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var _root_list = ds_list_create(); // list containing each wishlist created
  2.  
  3. var wishlist_size = ds_grid_height(wishlist_grid); // get the number of wishlists created
  4. for(var i=0;i<wishlist_size;i++) // loop through every wishlist in the grid
  5.     {      
  6.     // create submap that contains "wishlist" and "itemlist"
  7.     var _submap = ds_map_create();
  8.    
  9.     // create map for the wishlist
  10.     var _map_wish = ds_map_create();
  11.    
  12.     // get values
  13.     var _name = wishlist_grid[# 0,i]; // wishlist name
  14.     var _owner = wishlist_grid[# 1,i]; // owner id
  15.  
  16.     // add key/values to wishlist map
  17.     ds_map_add(_map_wish ,"name",_name); // save wishlist name
  18.     ds_map_add(_map_wish ,"owner",_owner); // save owner id of list
  19.    
  20.     // add wishlist map to the submap
  21.     ds_map_add_map(_submap,"wishlist",_map_wish);  
  22.  
  23.     // save every item in the item list
  24.     var item_list = ds_list_create(); // contains the itemlist
  25.    
  26.     var item_grid = wishlist_grid[# 2,i]; // get the pointer of item grid associated with the wishlist
  27.     var itemlist_size = ds_grid_height(item_grid); // number of items in the grid
  28.     for(var n=0;n<itemlist_size;n++) // loop through the grid
  29.         {  
  30.         // create the map for the item
  31.         var _map_item = ds_map_create();
  32.         ds_list_add(item_list,_map_item); // add the map to the item_list
  33.         ds_list_mark_as_map(item_list,ds_list_size(item_list)-1); // mark it as a map
  34.    
  35.         // get values
  36.         var _name = item_grid [# 0,n]; // item name
  37.         var _price = item_grid [# 1,n]; // item price
  38.  
  39.         // add key/values to itemlist map
  40.         ds_map_add(_map_item ,"name",_name); // save item name
  41.         ds_map_add(_map_item ,"price",_price); // save item price
  42.         }
  43.        
  44.     // add item_list to the submap
  45.     ds_map_add_list(_submap,"itemlist",item_list); // added to submap
  46.  
  47.     ds_list_add(root_list,_submap); // add the submap to the root_list
  48.     ds_list_mark_as_map(root_list,ds_list_size(root_list)-1); // mark as map
  49.     }
  50.  
  51. // wrap the data up
  52. var _wrapper = ds_map_create();
  53. ds_map_add_list(_wrapper,"ROOT",_root_list);
  54.  
  55. // save as string
  56. var _string = json_encode(_wrapper);
RAW Paste Data