Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gepard on Sat 27/07/2013 14:05:05

Title: Function question
Post by: Gepard on Sat 27/07/2013 14:05:05
Basically what I'm trying to do is to have a function that checks if a player has an inventory item, if not, than gives the player that item and than displays that item text property on a label. How can I do this?

Thanks!
Title: Re: Function question
Post by: Crimson Wizard on Sat 27/07/2013 14:28:48
Hey Gepard, long time no see :)

Code (ags) Select

function GiveItemIfDoNotHaveOne(InventoryItem *item)
{
   if (!player.HasInventory(item))
   {
      player.AddInventory(item);
      // Set label text
      lblItemName.Text = item.Name; // or item.GetTextProperty("property_name");
   }
   // optionally do something if player already has one
   else
   {
      Display("I have it already");
   }
}

Title: Re: Function question
Post by: Gepard on Sat 27/07/2013 16:06:20
Good to see you old friend and thanks for the help!