Inventory Item At Index

Started by Vincent, Thu 30/11/2017 22:28:04

Previous topic - Next topic

Vincent

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?

Khris

Something like this should work:

Code: ags
  int index;
  for (int i = 0; i < invWindow.ItemCount; i++) {
    if (invWindow.ItemAtIndex[i] == iOldItem) index = i;
  }
  player.LoseInventory(iOldItem);
  player.AddInventory(iNewItem, index);

Vincent

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.

Vincent

I had no doubts about it but it worked exceptionally fine! Thank you very much! :)

SMF spam blocked by CleanTalk