Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Global Lint on Mon 23/10/2006 21:27:11

Title: Hotspot has a different response on second click?
Post by: Global Lint on Mon 23/10/2006 21:27:11
How do you make a hotspot have a different response the second, third, fourth etc. time it is clicked?

Let's say you had a bookshelf hotspot.  Click it once and it will say, "The bookshelf contains many books."  Click it again and it will say, "There is a Harry Potter book."  Click it again and it will say, "There is also a horror novel." 

I have another question: How do you get it to display these messages in the same order after the third one ("There is also a horror novel") is clicked, skipping the first message? 
Title: Re: Hotspot has a different response on second click?
Post by: Candle on Mon 23/10/2006 21:36:48
http://americangirlscouts.org/bbc.com/yabb/index.php?topic=27947.0
Title: Re: Hotspot has a different response on second click?
Post by: Global Lint on Tue 24/10/2006 21:02:14
Ah, thanks, kind one :)

Oh, but I have another question.  What if you wanted a NON-player character to speak and say different responses?
Title: Re: Hotspot has a different response on second click?
Post by: Ashen on Tue 24/10/2006 23:57:57
Possibly, if you examine the MultiResponse Module's code, you'll find a way to get the MultiResponse text, and use it for an NPC.

However, to quote the BFAQ:
Quote
NOTE: Please keep the following in mind. Most of our problems can be easily solved using variables. Need to change a hotspot's state in another room? Use variables! Need an object to be used only once? Use variables! You can either use Global Integers and Global Strings (look inside the AGS manual for these) or custom variables. Look at the solution to that problem HERE under "Scripting, Code & Interaction".

So, you could use the old-fashioned method, e.g.:

// Top of global script
int response;

// Hotspot interaction
if (response == 0) cNpc.Say("Thing 1");
else if (response == 1) cNpc.Say("Thing 2");
else if (response == 2) cNpc.Say("Thing 3");
else if (response == 3) cNpc.Say("Thing 4");
else if (response == 4) cNpc.Say("Thing 5");
else if (response == 5) cNpc.Say("Thing 6");
// etc
response ++;


Creating an array (http://www.adventuregamestudio.co.uk/manual/Arrays.htm) (int response[AGS_MAX_CHARACTERS];) and using it instead of the int (if (response[cNpc.ID] == 0) { ...) might be a better way.
Title: Re: Hotspot has a different response on second click?
Post by: Global Lint on Wed 25/10/2006 00:17:34
Oh, dear... I'll try and sort all this out, but I'm not that sure I can...

*deep breath*  Here goes!
Title: Re: Hotspot has a different response on second click?
Post by: SSH on Wed 25/10/2006 15:11:31
MultiResponse can already do this:

cNPC.Say(Multi.SRespond("The bookshelf contains many books.>There is a Harry Potter book.>There is also a horror novel." ));
Title: Re: Hotspot has a different response on second click?
Post by: Global Lint on Wed 25/10/2006 17:27:47
Say, that's amazing!  Thanks a million!