GetTag

From ZDoom Wiki
Jump to navigation Jump to search

Actor

native clearscope string GetTag(string defstr = "") const

Usage

Returns the tag of the calling actor. If the actor does not have a tag and defstr is an empty string, the actor's class name is returned instead.

Parameters

  • String defstr
Optional. A string to return by default if the actor does not have a tag. Default is "" (an empty string), which is interepreted as "return actor's class name."

Examples

This is an example custom function that uses LineTrace to find an actor in front of the calling actor and then get its name:

String GetLooktargetName()
{
	FLineTraceData tr;
	LineTrace(self.angle, PLAYERMISSILERANGE, self.pitch, flags: TRF_ALLACTORS, offsetz: self.height*0.75, data: tr);
	if (data.hitType == TRACE_HitActor && data.HitActor)
	{
		return data.HitActor.GetTag();
	}
	return "";
}