Function: ObjectHasName
Function: ObjectHasName

Function: ObjectHasName

ObjectHasName ( OBJECT, NAME )

Checks if an object has an assigned name.

Parameters

Parameter Type Description
OBJECT OBJECT The object to inspect.
NAME VALUE(STRING) The name to test for.

Returns

VALUE(BOOLEAN) TRUE on a name match, FALSE on no match.

What It Does

This function inspects an object and returns TRUE if the provided name is one the names that the provided object is assigned, or FALSE if not.

Object names, when added to (but not removed from) objects, are sanitized, such that multi-word names only contain one space to separate words. For example, red     paint turns into red paint. Functions that check for matching names do not sanitize the name that is looked for.

Names are matched case-insensitively.

Example

Object Names Example


object o_ball named "ball" uses determiners "the";

world
{
	function nameTest(list)
	{
		local i;
		for (i = 0; i < length(list); i = i + 1)
			textln("Object has name \""+list[i]+"\": " + ObjectHasName(o_ball, list[i]));
	}

	start()
	{
		local names = [
			"ball", 
			"the ball", 
			"red ball", 
			"the red ball"
		];
		nameTest(names);

		textln("Adding \"red ball\"...");
		addObjectName(o_ball, "red ball");
		nameTest(names);
		
		textln("Removing \"ball\"...");
		removeObjectName(o_ball, "ball");
		nameTest(names);
		quit;
	}
}

See Also

AddObjectName() — Adds an interpretable name to an object.
RemoveObjectName() — Removes an interpretable name from an object.

×

Modal Header