Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: HereComeDatBoi on Thu 01/01/2009 06:48:33

Title: Help with script if (player.ActiveInventory)
Post by: HereComeDatBoi on Thu 01/01/2009 06:48:33
On my new game I would like to know the script so that I can check multiple items with if (player.ActiveInventory ==). This is the script i've used but I need some help.

function iSouthernwood_UseInv()
{
if (player.ActiveInventory == iSouthernwood){
(player.ActiveInventory == iSouthernwood)
(player.ActiveInventory == iSouthernwood)
(player.ActiveInventory == iSouthernwood)
(player.ActiveInventory == iSouthernwood)
(player.ActiveInventory == iSouthernwood)
(player.ActiveInventory == iSouthernwood)
(player.ActiveInventory == iSouthernwood)
(player.ActiveInventory == iSouthernwood)
(player.ActiveInventory == iSouthernwood)
(player.ActiveInventory == iVial)
player.LoseInventory(iSouthernwood);
player.LoseInventory(iVial);
player.AddInventory(iAConcoct);
Display ("Mixed the Southernwood in the Vial to create an Appleringie Concoction");
}
else Display ("You need 10 Southernwood herbs to produce an Appleringie Concoction!")
}


Thanks in advance
Title: Re: Help with script if (player.ActiveInventory)
Post by: Trent R on Thu 01/01/2009 07:26:10
Try
function iSouthernwood_UseInv()
{
  if ((player.ActiveInventory==iVial)&&(player.InventoryQuantity[iSouthernwood.ID]==10))
  {
    //do stuff
    player.InventoryQuantity[iSouthernwood.ID]-=10;
    player.LoseInventory(iVial);
    player.AddInventory(iAConcoct);
    UpdateInventory();
    Display ("Mixed the Southernwood in the Vial to create an Appleringie Concoction");
  }
  else Display ("You need 10 Southernwood herbs to produce an Appleringie Concoction!")
}


You want you use iVial on iSouthernwood, right?


~Trent
Title: Re: Help with script if (player.ActiveInventory)
Post by: HereComeDatBoi on Thu 01/01/2009 08:02:07
Thanks that will help alot!
Title: Re: Help with script if (player.ActiveInventory)
Post by: Shane 'ProgZmax' Stevens on Thu 01/01/2009 09:15:20
If for some reason you can carry more than 10 Southernwood, you'll need to change this line:


(player.InventoryQuantity[iSouthernwood.ID]==10)


to this


(player.InventoryQuantity[iSouthernwood.ID]>=10)


If this is just a one-shot puzzle though, it's fine.