• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Stacking inventory with ds_grid

A

AutoLiMax

Guest
Hi, I've pretty much finished creating an inventory system that's made using ds_grid. There is also a hot bar or quick bar that just displays items that are in the bottom row of the inventory.
The player can pick up items, move items around in the inventory, drop items and equip them but they currently don't stack.

I'm currently trying to figure out how to stack items. I just can't figure out how to go about doing it. I was thinking about having an amount variable in the itemInfo script but that wouldn't work if I want to add chests and other storage objects.
Maybe a second ds_grid which stores the item count? <-- This doesn't seam like the best way of going about it. I'm just looking for options really.

Does anyone have any ideas?

Thanks
 
Last edited by a moderator:
M

montiedragon

Guest
I'd store a ds_map in the grid to make it easier. It will let you store whatever variables you need as well as make it easier to read your code. So you could have something similar to this:
Code:
ds_grid_add(index here, x value here, y value here, ds_map_create());

inv_spot = ds_grid_get(index here, x value here, y value here);

ds_map_add(inv_spot, "item", item id or name);
ds_map_add(inv_spot, "maxStackable", set to 1 if its not stackable);
ds_map_add(inv_spot, "stats", info I just figured to add to give an example of other data to add);
ds_map_add(inv_spot, "lore", info I just figured to add to give an example of other data to add);
ect...
Warning: This is pseudo-code.
 
Top