Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Jojowl80 on Sat 04/07/2020 00:13:46

Title: player using all items
Post by: Jojowl80 on Sat 04/07/2020 00:13:46
I posted this in my Global Script

Code (ags) Select

function Arcus_UseInv()
{
if (player.ActiveInventory == iCcupfull)
if (player.HasInventory(iCcupfull))
player.Say("I thought you'd never ask.");
player.LoseInventory(iCcupfull);
player.AddInventory(iCcup);
}


but it does not matter which inventory item I use on him, it activates the script.
Title: Re: player using all items
Post by: Privateer Puddin' on Sat 04/07/2020 01:53:10
Try this?

Code (ags) Select

function Arcus_UseInv()
{
  if (player.ActiveInventory == iCcupfull) {
    if (player.HasInventory(iCcupfull)) {
      player.Say("I thought you'd never ask.");
      player.LoseInventory(iCcupfull);
      player.AddInventory(iCcup);
    }
  }
}


You shouldn't need both, since for it to be active inventory, you should already have it? but it should work if both conditions are met

Title: Re: player using all items
Post by: Jojowl80 on Sat 04/07/2020 03:34:48
perfect! thank you
Title: Re: player using all items
Post by: Crimson Wizard on Sat 04/07/2020 15:16:12
Jojowl80, you do not need to test if player HasInventory if ActiveInventory is same item, because ActiveInventory can be only one of the items player has.