Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: marypotter3 on Wed 21/09/2011 20:57:08

Title: Some questions about inventory and objects.
Post by: marypotter3 on Wed 21/09/2011 20:57:08
Hey! I have a few questions...

1 - How can I use my inventory when the GUI is hidden (called only by script)?
2 - How can I use a item from my inventory only in a determined situation?
3 - For example, the player gets a knife on his inventory, and then a new area of the game opens. How can I do that?

Thanks!
Title: Re: Some questions about inventory and objects.
Post by: pcj on Wed 21/09/2011 21:07:28
For simple checks to see if the player has the inventory item before moving to another room, use player.HasInventory(itemid);

So:

if (player.HasInventory(iKey)) player.ChangeRoom(3);


If you need to change the appearance of a particular room while the character is in it you can use the on_event function (this is built-in and doesn't require binding in the room editor):

function on_event(EventType event, int data) {
  if (event == eEventAddInventory) {
      if (data == iKey.ID) oDoor.Visible = false;
  }
}


         
Title: Re: Some questions about inventory and objects.
Post by: marypotter3 on Wed 21/09/2011 21:10:36
But how can I, in the moment of fight, show the inventory with the knife on it, if the inventory is hidden? What script can I use?
Title: Re: Some questions about inventory and objects.
Post by: pcj on Wed 21/09/2011 21:15:45
gInventory.Visible = true;

With the default settings, this will pause the game.  If you want to change that, just change the visibility setting on the gInventory properties pane to "Normal, initially off" or the respective setting as you want.
Title: Re: Some questions about inventory and objects.
Post by: marypotter3 on Wed 21/09/2011 21:33:41
Oh my god, I'm terrible at that. Can you just add me on msn, to help me with this part, please?