Label: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| (4 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
Labels allow associating a specific location in the object's code with a specific message. The object will move program execution to such a location in the following two cases: | Lines of ZZT-OOP beginning with a colon <code>:</code> are '''labels'''. | ||
Labels allow associating a specific location in the object's code with a specific '''message'''. The object will move program execution to such a location in the following two cases: | |||
* when explicitly requested by an object, including a different object, using [[Send|#send]]; | * when explicitly requested by an object, including a different object, using [[Send|#send]]; | ||
| Line 6: | Line 8: | ||
Labels should consist of Latin alphabet letters (A - Z) and underscores. They are not case sensitive - <code>TOUCH</code> , <code>Touch</code> and <code>touch</code> refer to the same message. | Labels should consist of Latin alphabet letters (A - Z) and underscores. They are not case sensitive - <code>TOUCH</code> , <code>Touch</code> and <code>touch</code> refer to the same message. | ||
The first occurrence of a label in the code is always used as the destination. To allow using additional occurrences of a label, labels can be [[Zap|zapped]], where they act as [[Comment|comments]] and will be ignored by [[Send|#send]] - for example, 'shot is the zapped form of the :shot label. | The first occurrence of a label in the code is always used as the destination. To allow using additional occurrences of a label, labels can be [[Zap|zapped]], where they act as [[Comment|comments]] and will be ignored by [[Send|#send]] - for example, <code>'shot</code> is the zapped form of the <code>:shot</code> label. | ||
== Quirks == | == Bugs/Quirks == | ||
* Labels must not be placed on the first line of an object's code; such a label will be ignored. | |||
* Non-alphabet characters, such as numbers, may be used as part of a label; however, if a label is followed by additional such characters, it is also considered a valid match for a given message. | * Non-alphabet characters, such as numbers, may be used as part of a label; however, if a label is followed by additional such characters, it is also considered a valid match for a given message. | ||
** For example, the message <code>touch</code> will match the label <code>:touch</code> as well as the labels <code>:touch</code> , <code>:touch1</code> and <code>:touché</code>, but not the labels <code>:toucha</code> or <code>:touch_1</code>. | ** For example, the message <code>touch</code> will match the label <code>:touch</code> as well as the labels <code>:touch</code> , <code>:touch1</code> and <code>:touché</code>, but not the labels <code>:toucha</code> or <code>:touch_1</code>. | ||
** Notably, this rule does ''not'' apply for the [[Restore|#restore]] command for the ''second'' and additional label occurrences, where an ''exact'' string match is required. | ** Notably, this rule does ''not'' apply for the [[Restore|#restore]] command for the ''second'' and additional label occurrences, where an ''exact'' string match is required. | ||
{{ZZT-OOP navbox}} | {{ZZT-OOP navbox}} | ||
Latest revision as of 16:23, 24 December 2025
Lines of ZZT-OOP beginning with a colon : are labels.
Labels allow associating a specific location in the object's code with a specific message. The object will move program execution to such a location in the following two cases:
- when explicitly requested by an object, including a different object, using #send;
- when the game engine causes one of the built-in messages to be sent to the object.
Labels should consist of Latin alphabet letters (A - Z) and underscores. They are not case sensitive - TOUCH , Touch and touch refer to the same message.
The first occurrence of a label in the code is always used as the destination. To allow using additional occurrences of a label, labels can be zapped, where they act as comments and will be ignored by #send - for example, 'shot is the zapped form of the :shot label.
Bugs/Quirks
- Labels must not be placed on the first line of an object's code; such a label will be ignored.
- Non-alphabet characters, such as numbers, may be used as part of a label; however, if a label is followed by additional such characters, it is also considered a valid match for a given message.
- For example, the message
touchwill match the label:touchas well as the labels:touch,:touch1and:touché, but not the labels:touchaor:touch_1. - Notably, this rule does not apply for the #restore command for the second and additional label occurrences, where an exact string match is required.
- For example, the message
| ZZT-OOP | |
|---|---|
| Prefixes |
|
| Messages | |
| Directions | |
| Flags | |
| Commands | |