Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Sun 27/02/2011 09:16:50

Title: SOLVED: Boolean to check if you have talked to another character
Post by: barefoot on Sun 27/02/2011 09:16:50
Hi

I'm trying to put some script together that checks if you have spoken to another character.

A bool where you could check true of false...

I did do a bool some time ago with the help from khris... but i need it to refer to something else and can't seem to find the right way of putting it in. I know the basics.

The boolean checks if you (cwizard) have spoken to a character (cbjork) so that when you talk to another character (cbergthora) what you say is determined by wheather the boolean is true or false..

I will check out booleans more..

All help/support appreciated

barefoot


Title: Re: Boolean to check if you have talked to another character and act on true / false
Post by: ThreeOhFour on Sun 27/02/2011 09:38:39
An easy way to do it:

Create a new boolean variable in the global variables pane called something like TalkedToBjork, set to false (although it doesn't matter really if you set it to false here)

When you click on cBjork with whatever mouse mode starts Bjork talking, have this somewhere in that function:

TalkedToBjork = true;

Then when you run the conversation with cBergthora, in either the global script or dialog script (wherever you've set it up), you can reference it:


cBergthora.Say("Did you ask Bjork about the shovel?");
if (TalkedToBjork == true)
{
  cWizard.Say("Yes, I have. She says you can have it.");
  cBergthora.Say("Great! Help yourself to my squishy carrot.");
}
else
{
  cWizard.Say("No, not yet.");
  cBerthora.Say("You shan't have my squishy carrot then!");
}


Hope this helps.
Title: Re: Boolean to check if you have talked to another character and act on true / false
Post by: monkey0506 on Sun 27/02/2011 09:39:55
If you understand the basics, as you say you do, then you understand that for a boolean value such as this that you would want an initial value of false, and then in whatever interaction script you have accomplished the required task, you would set the boolean to true.

In the interaction script where you need to check whether the required action has been accomplished, you would simply check the value of the boolean.

So, if you understand the basics, which means that you understand clearly how to accomplish all of the above, then this thread can be marked as solved, yes?

Edit: Good job getting that inb4cynicism Ben. :=

But seriously barefoot, if you can't even comprehend how to use a simple boolean variable like this, after, as you said, Khris has already shown you how to do this at least once, you might have bigger issues than simply whether or not the player has talked to a character. You seriously need to be able to solve problems like this yourself if you want to make a game with AGS. We don't mind helping you, of course, but we're not here to make your game for you, and you've already been told how to do this before.
Title: Re: Boolean to check if you have talked to another character and act on true / false
Post by: barefoot on Sun 27/02/2011 10:13:43
Hi

i appreciate both of your replies.. I just got a bit entangled that's all...  information overload and burnout...  I never need ask that question again... solved...

Thanks again
:=


barefoot