There was couple old topics about this problem but there wasnt clear solutions.
I use invisible npc's inventory as a secondary inventory to the player, but when i add items to the secondary inventory, sometimes items are invisible even if i use update inventory. In this topic (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=19265.0) someone said that multiply inventories dont work in earlier versions of AGS, but i use version 2.72.
Code where I add item to inventory:
if (player.activeinv == 5) {
player.LoseInventory(iHamburger);
cRefrigerator3.AddInventory(iHamburger);
}
if (player.activeinv == 10) {
player.LoseInventory(iGroundmeat);
cRefrigerator3.AddInventory(iGroundmeat);
}
(its in object's "use inventory on object" script)
Code where you "open the fridge" and inventory is displayed:
object[1].SetView(5);
object[1].Animate(0, 5, eOnce, eNoBlock, eForwards);
Wait(10);
gRefrigerator2.Visible = true;
UpdateInventory();
SetGlobalInt(eGRefrigeratorOpenClosed, 1);
and code when you take items from secondary inventory:
if (GetGlobalInt(eGRefrigeratorOpenClosed) == 1) {
cRefrigerator3.LoseInventory(iHamburger);
player.AddInventory(iHamburger);
UpdateInventory();
}
(its in inventory object's "other click on inventory item" script.)
thnx for any help.
EDIT: Forgot to say that items are invisible only sometimes, usually everything works fine.
As long as you use Character.AddInventory and Character.LoseInventory, there's no need to call UpdateInventory afterwards.
QuoteIf you add or remove inventory items manually (ie. by using the InventoryQuantity array rather than the AddInventory/LoseInventory functions), the display may not get updated. In this case call this function after making your changes, to update what is displayed to the player.
Try removing it.