Function: AddObjectTagToAllIn
Function: AddObjectTagToAllIn

Function: AddObjectTagToAllIn

AddObjectTagToAllIn ( OBJECTCONTAINER, TAG )

Adds a tag to each object in an object container.

Parameters

Parameter Type Description
OBJECTCONTAINER OBJECT-CONTAINER The object container element.
TAG VALUE(STRING) The tag to add to each object.

Returns

Returns nothing. Cannot be used in expressions.

What It Does

This function adds a tag to each object that is owned by a particular object container element. Adding tags that are already assigned to the provided objects does nothing.

Unlike names, tags are not sanitized on assignment to objects - they are added as-is.

Tags are matched case-insensitively.

Example

Object Tags Example


action general a_quit named "quit";
action transitive a_eat named "eat", "consume";
action transitive a_drive named "drive";
action transitive a_examine named "examine", "look at", "x";
action modal a_make named "make the thing", "make thing" 
	uses modes "edible", "not edible", "not driveable", "driveable", "inert";

object o_thing named "thing" uses determiners "the"
{
	onAction(a_eat)
	{
		if (objectHasTag(this, "edible"))
			textln("You ate the thing. Delicious!");
		else
			textln("You can't eat this.");
	}

	onAction(a_drive)
	{
		if (objectHasTag(this, "driveable"))
			textln("You drive the thing. Vroom!");
		else
			textln("You can't drive this.");
	}

	onAction(a_examine)
	{
		local edible = objectHasTag(this, "edible");
		local driveable = objectHasTag(this, "driveable");

		if (edible && driveable)
			textln("It's a driveable, edible thing.");
		else if (edible)
			textln("It's an edible thing.");
		else if (driveable)
			textln("It's a driveable thing.");
		else
			textln("It's a thing.");
	}

}

world
{
	init()
	{
		giveObject(this, o_thing);
	}

	start()
	{
		textln("There's a thing here.");
		textln(
			"You can change the characteristics of the thing by typing \"make the thing\" and a"
			+ "mode: \"edible\", \"driveable\", \"not edible\" or \"not driveable\". Then you can "
			+ "\"eat\" or \"drive\" it."
		);
		textln("Typing \"make the thing inert\" will remove those characteristics.");
		textln("");
		textln("Type \"quit\" to quit.");
	}

	onAction(a_quit)
	{
		quit;
	}

	onModalAction(a_make, "edible")
	{
		addObjectTag(o_thing, "edible");
		textln("The thing is now edible.");
	}

	onModalAction(a_make, "driveable")
	{
		addObjectTag(o_thing, "driveable");
		textln("The thing is now driveable.");
	}

	onModalAction(a_make, "not edible")
	{
		removeObjectTag(o_thing, "edible");
		textln("The thing is now not edible.");
	}

	onModalAction(a_make, "not driveable")
	{
		removeObjectTag(o_thing, "driveable");
		textln("The thing is now not driveable.");
	}

	onModalAction(a_make, "inert")
	{
		removeObjectTagFromAllIn(world, "edible");
		removeObjectTagFromAllIn(world, "driveable");
		textln("The thing is now inert.");
	}

}

See Also

ObjectHasTag() — Checks if an object has a specific tag.
AddObjectTag() — Adds a tag to an object.
RemoveObjectTag() — Removes a tag from an object.
RemoveObjectTagFromAllIn() — Removes a tag from each object in an object container element.

×

Modal Header