• 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!

DS_Grids Help

J

JayR

Guest
Is it possible to get the sum of all the same items in an inventory using DS_Grid?

I have 10 columns (10 slots).
Row 1 hold the item indexes.
Row 2 hold the stack amount.

I know I can use for loop to loop through all my slots and add the stack amounts individually. But is there a function that does this? The sum functions of ds_grid don't seem much of a help..
 
T

TimothyAllen

Guest
The ds grid sum function is the one you want. If its not working like you want, its likely you made a mistake. Post your code.
 
J

JayR

Guest
My codes are kinda everywhere now. I double checked the docs. The ds grid sum function "Returns the sum of all the cells within a region on a grid." It returns all. But I only need the sum of the same item within a row.
 
T

TimothyAllen

Guest
My codes are kinda everywhere now. I double checked the docs. The ds grid sum function "Returns the sum of all the cells within a region on a grid." It returns all. But I only need the sum of the same item within a row.
So are you saying that you have multiple slots with the same item and you want to add up the stacks for that particular item type. If your items are not sorted, then your only option is to loop through them as you suggested.
 
J

JayR

Guest
So are you saying that you have multiple slots with the same item and you want to add up the stacks for that particular item type. If your items are not sorted, then your only option is to loop through them as you suggested.
Yeap, that's right.
Ahh ok.. Seems like I should have stick with Arrays.
Thanks!
 
Top