i have been working on an inventory system for a few hours and at the moment i have 2 items and 2 slots and this is how i assign them…
function AddPotH(){
if(slot01_free){
slot01_icon = Pot_health;
Pot_health_int++;
slot01_int++;
slot01_free = false;
}
else if(slot01_free == false slot02_free == true slot01_icon == Pot_mana){
slot02_icon = Pot_health;
Pot_health_int++;
slot02_int++;
slot02_free = false;
}
else if(slot01_free == false slot02_free == true slot01_icon == Pot_health){
Pot_health_int++;
slot01_int++;
}
else if(slot01_free == true slot02_free == false slot02_icon == Pot_health){
Pot_health_int++;
slot02_int++;
}
else if(slot01_free == false slot02_free == false slot01_icon == Pot_health){
slot01_icon = Pot_health;
Pot_health_int++;
slot01_int++;
}
else if(slot01_free == false slot02_free == false slot02_icon == Pot_health){
slot02_icon = Pot_health;
Pot_health_int++;
slot02_int++;
}
else{
Debug.Log("Out of Bag space!");
}
}
a lot of script to assign just one item to any of two slots right
there must be an easier way… how can i script just a simple bit of code that checks weather the item you picked up is already assigned to any slot and if so adds it there (if it is stackable)
if not to assign it to the first empty one?