Please "Longhand" This Script (RESOLVED)

Hi All,

Please can somebody expand this script for me:-

if (sMaster==""){oMaster=(GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());}
	else{oMaster=GetTarget(sMaster);}

Here is the way I would like it expanded to help explain it to me. (i.e. This is my attempt to interpret, but I know it is wrong because it looks like there is more in there to do with OBJECT_SELF and another GetPCSpeaker.)

void main(string sTarget, int bForce, string sMaster, int bOverrideBehavior, int iForbidXP)
{
    object oMaster;
    	
    	if(sMaster == "")
    	{
    		oMaster=(GetPCSpeaker());
    	}
    	
    	else
    	{
    		oMaster=GetTarget(sMaster);
    	}
}

Therefore, I ask if anybody could complete my expansion correctly. Thanks,
Lance

#include "ginc_param_const"

void main(string sTarget, int bForce, string sMaster, int bOverrideBehavior, int iForbidXP)
{
    object oMaster;

   	if (sMaster == "")
    {
    	oMaster = (GetPCSpeaker());
		
		if (oMaster == OBJECT_INVALID)
		{
			oMaster = OBJECT_SELF;
		}
    }
    	
    else
    {
    	oMaster = GetTarget(sMaster);
    }
}

Hi Travus,

Thank you. :slight_smile:

I honestly think the “longhand” is much clearer than the “shorthand”, which still confuses me. :wink:

I will copy and paste that above the section I have as a reminder.

Lance.

1 Like

https://nwnlexicon.com/index.php/Ternary_Conditional
I just leave it here :slightly_smiling_face:

Thanks Aqvilinus,

I did not even know what to call this to begin searching for it! The Ternary_Conditional, good to know! Although it sounds dangerous. :wink:

Cheers, Lance.

1 Like

@Lance_Botelle I go into the Conditional Operator in a reasonable amount of detail in my TR’s Basics - Decicisions ebook. While written primarily for an NwN audience, almost all the information contained within it applies to NwN2 as well (AFAIK all the information on this operator applies to NwN2). So you might find it useful.

TR

Thanks TR

I will be sure to bookmark it / download a copy. :slight_smile:

Lance.