Some questions about inventory and objects.

Started by marypotter3, Wed 21/09/2011 20:57:08

Previous topic - Next topic

marypotter3

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!

pcj

For simple checks to see if the player has the inventory item before moving to another room, use player.HasInventory(itemid);

So:
Code: ags

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):

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


         
Space Quest: Vohaul Strikes Back is now available to download!

marypotter3

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?

pcj

Code: ags
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.
Space Quest: Vohaul Strikes Back is now available to download!

marypotter3

Oh my god, I'm terrible at that. Can you just add me on msn, to help me with this part, please?

SMF spam blocked by CleanTalk