Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gribbler on Fri 23/01/2009 23:40:02

Title: how to use many items on one hotspot?
Post by: Gribbler on Fri 23/01/2009 23:40:02
Here's the deal. I have a hotspot and I want the player to say various things depending which item he uses on that hotspot.

Code:

function hDRAIN_PIPE_UseInv()
{
player.ActiveInventory = iNOTEBOOK;
player.Say("Why would I want to stick it in there?");

player.ActiveInventory = iHANDSAW;
player.Say("Why would I want to stick it in there?");

player.ActiveInventory = iSHIRT;
player.Say("Why would I want to stick it in there?");

player.ActiveInventory = iBUCKET;
player.Say("I can't.");
player.Say("The drain pipe is dry.");

}

Now the error I'm getting is this that the player doesn't have one of the items, and the game crashes. But he may have that item later on in the game and use it then. What can I do to make player say various things with using many different items? For example: a hotspot on which player can use every single item which will be available in the game.
Title: Re: how to use many items on one hotspot?
Post by: Valentine on Fri 23/01/2009 23:52:37
I think you're missing 'If', so it would be;

if player.ActiveInventory = iNOTEBOOK; {
player.Say("Why would I want to stick it in there?"); }
Title: Re: how to use many items on one hotspot?
Post by: Dualnames on Sat 24/01/2009 00:18:44
if (player.ActiveInventory == iNOTEBOOK){
//functions go here
}



Title: Re: how to use many items on one hotspot?
Post by: Gribbler on Sat 24/01/2009 11:36:20
thanks dualnames, that worked.
Title: Re: how to use many items on one hotspot?
Post by: Galen on Sat 24/01/2009 13:17:45
Yeah, you were just setting the players active inventory item to iWhatever each time.

if (player.ActiveInventory == iNOTEBOOK)
Will work (remember: '=' for setting things, '==' for comparing things).