How to remove an item from the inventory when used?

Started by Scrungo, Sat 05/09/2020 03:27:04

Previous topic - Next topic

Crimson Wizard

#20
Yes you may simply post it here.

Anyway, I checked out the game you sent me via PM, and I found what's wrong. Here's what you have in your Global Script:
Code: ags

function iPillow_Interact()
{
  cRoger.AddInventory(iPillow);
}


Basically, every time you click on the pillow in inventory it is picked up again, and its amount increases by 1 in addition to 1 you've got by picking it up. LoseInventory decreases its amount only by 1, so you are still left with 1 or more pillows.


You may diagnose things like this using Cassiebsg's suggestion she posted above:
Quote from: Cassiebsg on Sat 05/09/2020 10:17:52
Maybe you have just picked up the pillow more than once and when you lose it, you only lose 1 of them, thus at least one remains in inventory?
Try setting the Display multiple icons  for multiple items=true and see if your character then happens to have more than one pillow in inventory.

Another way is to use "Display" function to show current values:
Code: ags

Display("Number of pillows: %d", player.InventoryQuantity[iPillow.ID]);

SMF spam blocked by CleanTalk