The text appears when the PC is in a certain area

I would need a simple script to be applied to a conversation only if the character is in a certain area (resref).

This little script assumes that you have stored the area that the PC must be in, actually on the PC and called “oTestingArea”.

void main()
{
    object oPC = GetPCSpeaker();
	object oPCArea = GetArea(oPC);
	object oTestArea = GetLocalObject(oPC, "oTestingArea");

    if(oPCArea == oTestArea)
	{
		//do your script here
	}
}

Is that what you wanted? You weren’t very specific in your query.

TR

Given that my English leaves something to be desired, I will explain myself better.

I have to create an identical conversation for many png, I need some nodes of the conversation to be visible to the PC only if it uses that conversation in a specific area.

Thanks for the help Tarot

int StartingConditional()
{
object oPC = GetPCSpeaker();
object oPCArea = GetArea(oPC);
object oTestArea = GetLocalObject(oPC, “oTestingArea”);

if(oPCArea == oTestArea)
    return FALSE;
    return TRUE;

}

Almost but it can be simplified -

int StartingConditional()
{
	object oPC = GetPCSpeaker();
	object oPCArea = GetArea(oPC);
	object oTestArea = GetLocalObject(oPC, “oTestingArea”);

	return(oPCArea == oTestArea)
	//return(oPCArea != oTestArea)
}

What happen is that the uncommented return does the test and then returns TRUE if they match and FALSE if they don’t. Should you need it to work in the opposite way just comment out the first one and uncomment the second.

You might find it useful to grab the truth tables in this.

TR

3 Likes

Areas can be found and targeted via GetObjectByTag, too. Cutting it down a little more:

int StartingConditional()
{
    object oPC = GetPCSpeaker();
    object oArea = GetObjectByTag("testarea");

    return (GetArea(oPC) == oArea);
    // return (GetArea(oPC) != oArea);
}
2 Likes

Thank you both

TR: gives me a compilation error.

You need to supply the missing semi-colon yourself. TR was running low.

4 Likes

Oh, bu!!$!r. That’s what you get when you’re in too much of a hurry. As @meaglyn says it’s down to missing semi-colons. I use the plural because both return statements are missing them. Sorry.

TR