Object Element
Object Element

Object Element

The most-used element in a module are objects. These can be moved between all of the object containers (world, player, room, container) and is the common element that is targeted by actions.

Where objects are contained dictate their accessibility, as well as the current player or room. The currently accessible objects also affect how user input is interpreted.

Declaration


	object [INDENTIFIER] [INHERITANCE_CLAUSE] [NAME_CLAUSE] [DETERMINER_CLAUSE] [TAG_CLAUSE]
	{
		/* Lifecycle */
		init() { ... }

		/* Events */
		onAction(action) { ... }
		onActionWith(action, object) { ... }
		onActionWithAncestor(action, object) { ... }
		onActionWithOther(action) { ... }
		onElementBrowse(element) { ... }
		onRoomBrowse() { ... }
		onPlayerBrowse() { ... }
		onWorldBrowse() { ... }
		onContainerBrowse() { ... }
	}
[IDENTIFIER] An internal identifier that represents this object in the rest of TAMEScript. This is used to find what entry blocks throughout the code should be executed when this object is parsed by the interpreter or when a specific action is queued by another command. This identifier must not be used to describe another element.
[INHERITANCE_CLAUSE] If this object inherits entry points and functions from another object, you declare its parent object by adding a colon (:) plus the identifier of the parent object.
[NAME_CLAUSE] The keyword named followed by a comma-delimited list of strings that the interpreter is supposed to associate with this object at initial state. Objects can share names, but without distinct names to refer to an object as, more than one accessible object referred to by the same name will cause ambiguous command errors.

This clause is optional - if no names are declared, this object is not parse-able in the interpreter until names are added to it (via AddObjectName()). An object's determiners affect what names get assigned to this object, as well.

An object does not need a parse-able name in order to exist or have an owner, and even though it is not accessible via interpreter, it may be accessible according to a PlayerCanAccessObject() function call.
[DETERMINER_CLAUSE] The keywords uses determiners followed by a comma-delimited list of strings that TAME assigns as determiners to this particular object at initial state.

A determiner is an optional prefix added to object names to make them parse-able in the interpreter. For example, if an object had the determiner the and the name book, The names associated are "book" and "the book".

This clause is optional. Determiners cannot be added later in module execution.
[TAG_CLAUSE] The keyword tagged followed by a comma-delimited list of strings that TAME assigns as tags to this particular object at initial state.

This clause is optional - if no tags are declared, they can still be added later (via AddObjectTag()).

Entry Blocks

Command Name Parameters Description
Init None Called at module context initialization on each element.
OnAction ACTION Called when an action needs to be processed on a specific element. Action type decides the element entry point.
OnActionWith ACTION, OBJECT Called when a [di]transitive action needs to be processed with a specific object.
OnActionWithAncestor ACTION, OBJECT Called when a [di]transitive action needs to be processed with a matched ancestor object (if OnActionWith is unhandled).
OnActionWithOther ACTION Called when a [di]transitive action needs to be processed with a valid object, but the object is not handled by OnActionWith or OnActionWithAncestor.
OnElementBrowse OBJECT-CONTAINER Called when Browse() is called while this object is owned by a specific element (or parent element). Most specific chosen first.
OnWorldBrowse None Called when Browse() is called while this object is owned by a world.
OnRoomBrowse None Called when Browse() is called while this object is owned by a room.
OnPlayerBrowse None Called when Browse() is called while this object is owned by a player.
OnContainerBrowse None Called when Browse() is called while this object is owned by a container.

Archetyping

The keyword archetype can be used to create objects that have common functions and entry points to share among similar objects. Archetyped objects can inherit from other parent objects and archetyped objects, but do not specify names, tags, nor determiners, since they are not "real" objects.

Archetyped objects also cannot be used in commands as through they were real elements. Archetypes also do not hold a context state, nor is their context state saved.


	object archetype [INDENTIFIER] [INHERITANCE_CLAUSE]
	{
		/* Lifecycle */
		init() { ... }

		/* Events */
		onAction(action) { ... }
		onActionWith(action, object) { ... }
		onActionWithAncestor(action, object) { ... }
		onActionWithOther(action) { ... }
		onElementBrowse(element) { ... }
		onRoomBrowse() { ... }
		onPlayerBrowse() { ... }
		onWorldBrowse() { ... }
		onContainerBrowse() { ... }
	}

Prototyping and Extending

TAMEScript's compiler is single-pass: it parses through the module code once, so if the compiler encounters an object identifier that has not been declared yet, it may need to be prototyped.

Prototyping an object is essentially declaring an object, but with a semicolon after its main declaration instead of a declaration body wrapped in curly-braces ({ }). A parent object, names, tags, and determiners, if any, will still need to be declared here.

If you have already declared an object as a prototype (or with a declaration body) and wish to add to it later in code, you'll need to extend it using the extend keyword. When using extend, you cannot change its lineage (parent) or its initial names, tags, or determiners.


	object o_ball named "ball";
	
	extend object o_ball
	{
		/* ...stuff goes here... */
	}

Object Element

Object Element

×

Modal Header