Jibble

Author Topic: Why aren't these added inventory items showing up?  (Read 93 times)

bx83

  • Get 'Er Doooooone
I've added this piece of code - it's supposed to transfer inventory items from cDummy to player (cJulius):

Code: Adventure Game Studio
  1.   //lose playerstartswith items from inventory - now it's totally empty
  2.   cJulius.LoseInventory(iKnife);
  3.   cJulius.LoseInventory(iRope);
  4.   cJulius.LoseInventory(iNotepad);
  5.  
  6.   cDummy.AddInventory(iCarCoolant); //4
  7.   cDummy.AddInventory(iCarPetrol);  //5
  8.   cDummy.AddInventory(iFacePlate);  //6
  9.   cDummy.AddInventory(iFuzzyDice);  //8
  10.  
  11.   cJulius.AddInventory(iFurstPrize);    //68
  12.  
  13.   //get all other inventory items
  14.   for (int i = 1; i <= 10; i++) {
  15.     player.InventoryQuantity[i] = cDummy.InventoryQuantity[i];
  16.  
  17.     //the below 2 lines report that items 4, 5, 6, and 8 are '1' for both
  18.     Display("dummy %d inventory %d",i, cDummy.InventoryQuantity[i]);
  19.     Display("julius %d inventory %d",i, player.InventoryQuantity[i]);
  20.  
  21.     //set dummy inventory quantity to 0 - delete this item from the inventory
  22.     cDummy.InventoryQuantity[i] = 0;
  23.   }

Then I have a look at the inventory - only iFurstPrize (68) is in there, not items 4, 5, 6, and 8.
Same thing happens if I put 'cJulius' instead of 'player'.

What's going on?

This is a modified version of the code used in the game, given to me by CrimsonWizard a while ago, to transfer items between 2 inventories.
« Last Edit: 16 Aug 2019, 10:31 by bx83 »

Matti

Re: Why aren't these added inventory items showing up?
« Reply #1 on: 16 Aug 2019, 10:42 »
The help file entry on InventoryQuantity says: "If you change this array directly, the on-screen inventory will not be updated. In this case, you must call UpdateInventory to see any new or removed items."

That might be the problem.

bx83

  • Get 'Er Doooooone
Re: Why aren't these added inventory items showing up?
« Reply #2 on: 16 Aug 2019, 12:10 »
Works :)
Thanks :)

Matti

Re: Why aren't these added inventory items showing up?
« Reply #3 on: 17 Aug 2019, 13:30 »
I'm glad to be of help  :)

Btw, it would be convenient if you put a [SOLVED] in your thread's titles so that people know that there's no need for help anymore.