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

SOLVED A way to store which slot you picked up the item?

Rexzqy

Member
Hi, I am trying to implement the food spoil system, and for this i either have to check through the backpack every few seconds to see if theres any food item in there, or maybe is there a way to tell the code to store which slot you picked up the item? I uses local variable so i am not sure how am i supposed to do that. Any help will be greatly appreciated! Below is my code:

var yy=0; repeat(inv_slots)
if inst.spoil = ds_inv[# 4,yy]
{
if inst.spoil > -1
{
ds_inv[# 5,yy] = 1;
}
ds_inv[# 4,yy] = inst.spoil;

}
else if inst.spoil != ds_inv[# 4,yy]
{
ds_inv[# 4,yy] = (inst.spoil+(ds_inv[# 1,yy]-1)*ds_inv[# 4,yy])/ds_inv[# 1,yy];
if inst.spoil > -1
{
ds_inv[# 5,yy] = 1;
}
}

So yy is the slot number, and please help me if theres anyway to store this!
 

Rexzqy

Member
Yeah. Save yy to a variable that wasn't initialized with var in front of it.
Thx for your help! With some testing though i found out even if the backpack is filled with food items, it still wouldnt lag the game. I will certainly try that if later it proves to be a burden! But for now it seems it works ok.
 
Top