I don't know if I'm missing something, but is there an easy way to remove all inventory items at once, without checking for it first?
yes and no
You need a while loop (or something similar)
something like: check how many inventory items the player has, then subtract 1 (with LoseInventoryItem) until the player has 0.
Quote from: Cassiebsg on Tue 17/07/2018 20:23:42
You need a while loop (or something similar)
something like: check how many inventory items the player has, then subtract 1 (with LoseInventoryItem) until the player has 0.
It's faster with InventoryQuantity:
// This removes literally all items from player's inventory
for (int i = 1; i < Game.InventoryItemCount + 1; i++) // inventory IDs begin with 1
player.InventoryQuantity[i] = 0;
// This removes only particular items
player.InventoryQuantity[iMyItem.ID] = 0;
UpdateInventory(); // You must call this to force update on-screen inventory window
EDIT: fixed script.
Thanks. It's funny, I just assumed there would be a simple function to reset the inventory.
This doesn't really work for me, either in room_Load or room_AfterFadeIn. Either way, it brings up the same error message: Character.InventoryQuantity: invalid inventory index 0.
Right, the inventory IDs begin with 1, so
for (int i = 1; i < Game.InventoryItemCount + 1; i++)
player.InventoryQuantity[i] = 0;
Thanks, I accidentally typed in 0, instead of 1
Quote from: TDBFW1 on Wed 18/07/2018 14:51:44
Thanks, I accidentally typed in 0, instead of 1
I also typed 0 myself at first. :)
Also, it was InventoryItemCount not ItemCount. Don't remember this by heart.