Object name

From Wiki of ZZT
Jump to navigation Jump to search

An object name in ZZT-OOP allows for an object to be referenced by other objects. A name is assigned using the @ character and some text on the first line of an object's code.

An object's name, if provided, will appear at the top of banner of the scroll window for an object or scroll. This can be very useful for things such as distinguishing multiple NPCs, providing subtle hints to the player, making a cheap one-line joke, etc. If a name is not provided, then the string "Interaction" appears instead.

In code, object names are most commonly used to provide a specific target for a #send command. They are also commonly used with the #bind command to share code between objects.

Less commonly, object names can be used to perform a remote #zap or #restore of another object's labels. They can also be used for remote hyperlinks.

One thing to keep in mind is that while text boxes display the entire line following the @ in their header, that only the first word on that line is considered for ZZT-OOP code (TODO: provide a rigorous definition of "word" in this context). This also means that it is possible to make an object have a display name that cannot be as a reference name in code.

Example

Say we have this object:

@Jazzman Jones
#end
:sing
$
$"I got my problems..."
$
$"...and my problems got me."
$
#end

To make Jazzman Jones here sing, another object on the board would need to run the command #send Jazzman:sing. The text Jazzman Jones would appear in the header of the textbox.

Quirks

  • #zap restart and #restore restart mangle the second character of an object's code, which would render its name unusable. This could be used intentionally if you really wanted to.

Memory Conservation

An object's name does not necessarily have to be make sense to a human reader. On particularly crowded boards approaching the memory limit, it may be good practice to abbreviate object names to conserve memory. When doing so, it is recommended to keep an external reference of object names for documentation purposes.