Jibble

Author Topic: Why aren't these added inventory items showing up?  (Read 183 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: [Select]
  //lose playerstartswith items from inventory - now it's totally empty
  cJulius.LoseInventory(iKnife);
  cJulius.LoseInventory(iRope);
  cJulius.LoseInventory(iNotepad);
 
  cDummy.AddInventory(iCarCoolant); //4
  cDummy.AddInventory(iCarPetrol);  //5
  cDummy.AddInventory(iFacePlate);  //6
  cDummy.AddInventory(iFuzzyDice);  //8
 
  cJulius.AddInventory(iFurstPrize);    //68

  //get all other inventory items
  for (int i = 1; i <= 10; i++) {
    player.InventoryQuantity[i] = cDummy.InventoryQuantity[i];

    //the below 2 lines report that items 4, 5, 6, and 8 are '1' for both
    Display("dummy %d inventory %d",i, cDummy.InventoryQuantity[i]);
    Display("julius %d inventory %d",i, player.InventoryQuantity[i]);

    //set dummy inventory quantity to 0 - delete this item from the inventory
    cDummy.InventoryQuantity[i] = 0;
  }

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.