Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Wed 29/12/2010 11:53:10

Title: if a char has spoken to another char then do this...
Post by: barefoot on Wed 29/12/2010 11:53:10
Hi

I was wondering if there is a function for if a char has spoken to another char then do this or if not do this etc

IE when char is on a region it checks if he has spoken to another char in same room.

Cheers

barefoot
Title: Re: if a char has spoken to another char then do this...
Post by: Mouth for war on Wed 29/12/2010 12:06:55
couldn't you use a variable for that?
like
//At the top of the script
int talk=0;

and when the character has talked to another character change talk to 1
and when the the character is on a region...

function region1_WalksOnto()
{
if (talk ==0){
dcharacter.Start(); //or whatever the name of your dialog is
}
else if (talk ==1){
Display ("I've already talked to him");}
}

don't know if that's what you're after but hopefully it's something like that you're searching for :)
Title: Re: if a char has spoken to another char then do this...
Post by: barefoot on Wed 29/12/2010 13:20:13
Hi

Good old Int... 

cheers
barefoot
Title: Re: if a char has spoken to another char then do this...
Post by: Sslaxx on Wed 29/12/2010 13:23:36
Quote from: Mouth for war on Wed 29/12/2010 12:06:55
couldn't you use a variable for that?
like
//At the top of the script
int talk=0;

and when the character has talked to another character change talk to 1
and when the the character is on a region...

function region1_WalksOnto()
{
if (talk ==0){
dcharacter.Start(); //or whatever the name of your dialog is
}
else if (talk ==1){
Display ("I've already talked to him");}
}

don't know if that's what you're after but hopefully it's something like that you're searching for :)
I'm wondering if you could do that with DoOnceOnly. http://www.adventuregamestudio.co.uk/manual/Game.DoOnceOnly.htm


function region1_WalksOnto()
{
if (Game.DoOnceOnly ("Talking to a guy here"))
{
  dcharacter.Start(); //or whatever the name of your dialog is
} else
{
  Display ("I've already talked to him");
}
}
Title: Re: if a char has spoken to another char then do this...
Post by: Khris on Wed 29/12/2010 14:02:06
That depends. If the region is supposed to trigger the dialog (suggested by Mouth for war, not barefoot), but only the first time, then yes.
If the player walks into a light barrier that is deactivated by talking to a guard first, then no.

In other words, mentioning Game.DoOnceOnly is a good thing since it is sufficient for many situations where we had to use a variable before, but spreading the word about the proper use of variables is much more important.
Title: Re: if a char has spoken to another char then do this...
Post by: Tamanegi on Thu 30/12/2010 18:07:39
Also remember that using "if (DoOnceOnly("blah")==false)" still uses up the DoOnceOnly, so any further uses will result in "false".
Title: Re: if a char has spoken to another char then do this...
Post by: Khris on Fri 31/12/2010 17:37:01
True, but the whole condition will be false the first time, then true.
As long as you don't check DoOnceOnly with the same string twice or even more, you're fine.
Title: Re: if a char has spoken to another char then do this...
Post by: Tamanegi on Fri 31/12/2010 22:31:08
To prevent any misunderstandings:

DoOnceOnly("blah")  is true the first time, so the statement "if (DoOnceOnly("blah")==false)" is false. After that, it's false, so "==false" will become true.
Basically, it's a oneshot thing.

I was a little confused at first... it should really be named "IsTrueOnceOnly" ;-)