Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Vincent on Thu 30/11/2017 22:28:04

Title: Inventory Item At Index
Post by: Vincent on Thu 30/11/2017 22:28:04
Good evening to all AGSer folks!

I really hope that you're not tired for my noob questions.
The thing that I am going to ask you today it seems much simple to do, but at the moment I really can't find a good solution to it. So, I need to add an inventory item to a specific index, more specifically, where it was a certain item before to removing it. Well, into the manual I could find something like this: readonly InventoryItem* InvWindow.ItemAtIndex[]; but how I could use this for my purpose? How do you check where it is exactly a certain item into the inventory window?
Title: Re: Inventory Item At Index
Post by: Khris on Thu 30/11/2017 23:27:27
Something like this should work:

  int index;
  for (int i = 0; i < invWindow.ItemCount; i++) {
    if (invWindow.ItemAtIndex[i] == iOldItem) index = i;
  }
  player.LoseInventory(iOldItem);
  player.AddInventory(iNewItem, index);
Title: Re: Inventory Item At Index
Post by: Vincent on Thu 30/11/2017 23:40:34
Awesome Khris!

Thank you very much for your kind help.
I have to leave my workstation for now but I will let you know as soon as possible on tomorrow.
I really can't wait to test this!
Thank you very much again and have a good night.
Title: Re: Inventory Item At Index
Post by: Vincent on Fri 01/12/2017 09:38:20
I had no doubts about it but it worked exceptionally fine! Thank you very much! :)