Heya,
Brain fog today ???
Is there a way to simply get the ID of a active inventory item so i can achieve something like:
function iBottomlessBag_UseInv()
{
if (player.ActiveInventory) {
player.LoseInventory(inventory[ID]);
}
}
I attempted to make a var such as "get_inv_id" which stores the inventory ID when interactive with it, then using
player.LoseInventory(inventory[get_inv_id]);
But it was messy and didn't feel right
Every fixed object in AGS has ID property:
https://adventuregamestudio.github.io/ags-manual/InventoryItem.html#inventoryitemid
But for above code you don't need it at all, as LoseInventory() function accepts InventoryItem, and ActiveInventory is already InventoryItem.
if (player.ActiveInventory) {
player.LoseInventory(player.ActiveInventory);
}
https://adventuregamestudio.github.io/ags-manual/Character.html#characteractiveinventory
https://adventuregamestudio.github.io/ags-manual/Character.html#characterloseinventory
Today for most cases you don't need IDs, unless you are using them for cross-references with your own custom data.
Ah ok i knew it had to be something simple, just one of those days...
Thank you.
Edit:
I'll be sure to check out the links you've shared, i do always try to find a solution to a problem via the manuel and other sources, but if i'm at a loss i find it's easier to share the code a give an explanation on what i'm trying to achieve.
Just for reference, you could've used
player.LoseInventory(inventory[player.ActiveInventory.ID]); // pretty pointless though