I’ve got a simple script question that I’m sure a lot of you can answer. I’ve got a custom speaktrigger with a script like this.
#include "ginc_trigger"
void main ()
{
object oPC = GetEnteringObject();
object oPriestess = GetNearestObjectByTag("priestess",oPC);
if(!GetIsPC(oPC)) return;
if (StandardSpeakTriggerConditions(oPC) == FALSE)
{
return;
}
if (!GetFactionEqual(oPC,oPriestess))
{
return;
}
DoSpeakTrigger(oPC);
}
If the object with the tag “priestess” isn’t in the area at all, will the script still do a return to void? I mean, it just struck me, if it can’t find the object with the tag at all, will it still come to the conclusion that the object isn’t of the same faction as oPC, or will the game get confused and do nothing?
By combining the original multiple if() statements into a single if() and relying on short-circuit processing of the conditions (in a statement containing multiple &&s the first condition (starting at the leftmost and going right) that returns FALSE terminates processing of all the conditions and returns FALSE) we can remove all those return statements.