Jump to content


Saving an inventory in a DS_Grid


  • Please log in to reply
No replies to this topic

#1 Timelordlaxx


    GMC Member

  • New Member
  • 1 posts
  • Version:GM:Studio

Posted 29 March 2016 - 07:38 AM

I'm creating an inventory system, and I want to be able to save it when the game saves and then load it when the game is loaded.


The inventory system uses a DS_Grid to save the id of each item how many there are ETC.


Saving the game uses a DS_Map that saves into a JSON file. Though I'm not sure this is the best way to go about that. Anyway, when I move an item from slot 1 to slot 3 save the game then shut down and when i turn the game back on and hit load the item has reset to its initial position that was set in the object create function of the inventory. 

maxItems = 5;
globalvar mouseItem;
mouseItem = -1;
global.inventory = ds_grid_create(maxItems, 4);
    for (i = 0; i < maxItems; i += 1){
        global.inventory[# i, 0] = -1;
        button[i] = instance_create(0,0,oInvButton);
        button[i].slot = i;

instance_create(0,0, oItemMouse);

I can only assume that this create event is overwriting everthing I do, so...how would I go about fixing this?

  • 0

Also tagged with one or more of these keywords: gm:studio