Types

Type definition blocks define a set of properties and/or actions. An object can then obtain all of these properties and actions by including a type tag in its definition block.

Type definition blocks are of the following form:

define type <type name>
	type <(another type name)>
	.
	.
	.
	property [ = (value) ]
	.
	.
	.
	action <(action name)> (script)
	.
	.
	.
end define

Type definition blocks themselves can include type tags, thereby allowing you to create sophisticated object types based on other object types. Any properties and actions specified will override equivalent properties and actions included by a type tag.

See the object properties tag for more information on properties, and see the object action tags for more information on actions.

Any define type <default> block will have all its properties and actions apply to all objects in the game. Similarly, any define type <defaultroom> block will have all its properties and actions apply to all rooms in the current game.

Within an action, you can find out which object is responsible for calling the script by using the $thisobject$ function, which will return the object name. The $thisobjectname$ function returns the object's displayed name. For example:

define type <edible>
	action <eat> {
		msg <You stuff the $thisobjectname$ in your face. Lovely.>
		move <$thisobject$; stomach> }
end define

define room <Dining Room>
	command <eat #@food#> doaction <#food#; eat>

	define object <chips>
		type <edible>
	end define

	define object <veg1>
		alias <potato>
		type <edible>
	end define
end define

 

< Back