Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Fri 25/06/2004 01:08:15

Title: Help with Inventory Conditional
Post by: on Fri 25/06/2004 01:08:15
I know what I want to happen, but I don't know how to put into the scripting language.
What I want to happen is this: If player has used a certain inventory item on object 1, then hotspot 3 runs a different script than it normally would when clicked on.

The "Conditional--If Inventory Item was Used" only lets me change the reaction of the object, when I want to change the reaction of the hotspot. See?

If haven't made myself clear enough, I'll re-explain if I need to.

As always, any help is greatly appreciated, and rewarded with eternal gratitude and cupcakes. And possibly puppies.

--OftenK
Title: Re: Help with Inventory Conditional
Post by: Wolfgang Abenteuer on Fri 25/06/2004 01:12:56
What you have to do is set some sort of variable that tells the game if the player has clicked the inventory item on the object.Ã,  Something like this:

Under the "If inventory item was used on object" script:

itemclicked = 1;
//Whatever other code you need


Then under the hotspot interaction:

if (itemclicked == 0) { //Player HASN'T clicked the item on the object
Ã,  //Run whatever code goes here
}
else if (itemclicked == 1) { //Player HAS clicked the item on the object
Ã,  //Run whatever code goes here
}


~Wolfgang
Title: Re: Help with Inventory Conditional
Post by: on Fri 25/06/2004 01:30:08
Quote from: Wolfgang Abenteuer on Fri 25/06/2004 01:12:56
What you have to do is set some sort of variable that tells the game if the player has clicked the inventory item on the object.Ã,  Something like this:

Under the "If inventory item was used on object" script:

itemclicked = 1;
//Whatever other code you need


Then under the hotspot interaction:

if (itemclicked == 0) { //Player HASN'T clicked the item on the object
Ã,  //Run whatever code goes here
}
else if (itemclicked == 1) { //Player HAS clicked the item on the object
Ã,  //Run whatever code goes here
}


~Wolfgang

It gives me an error saying "Error compiling your script. The problem was: In: 'Main Script' Error (line 8): Undefined symbol "itemclicked".

I must be doing something wrong. I'm puttin the first bit of script in the object interaction, and the last two bits in the hotspot interaction...right?
Title: Re: Help with Inventory Conditional
Post by: Wolfgang Abenteuer on Fri 25/06/2004 01:36:15
Right, but you need to first define the integer before you can use it.  Just put:

int itemclicked;

in the top of the room script (just click the double-brackets button in the room editor for that room and type it at the very top, before any room functions are declared).

~Wolfgang
Title: Re: Help with Inventory Conditional
Post by: on Fri 25/06/2004 01:48:22
Ha ha! Beautiful!

Thank you, sir. You've been a huge help!