Text: Difference between revisions
(Fleshed out the article quite a bit) |
(Add element ID for white on light gray text, prefix hex values in infobox) |
||
Line 5: | Line 5: | ||
|zzt-oop name=N/A | |zzt-oop name=N/A | ||
|id=Multiple, used to encode background color: | |id=Multiple, used to encode background color: | ||
* | * 0x2F: Blue | ||
* | * 0x30: Green | ||
* | * 0x31: Cyan | ||
* | * 0x32: Red | ||
* | * 0x33: Purple | ||
* | * 0x34: Brown | ||
* | * 0x35: Black | ||
|color=White foreground; element ID determines background | |color=White foreground; element ID determines background | ||
|char=Any (determined by tile's color byte) | |char=Any (determined by tile's color byte) | ||
Line 25: | Line 25: | ||
Text is also the only element supported by the built-in editor that has no ZZT-OOP name: e.g., there is no way to change all text tiles to another element type. | Text is also the only element supported by the built-in editor that has no ZZT-OOP name: e.g., there is no way to change all text tiles to another element type. | ||
== Usage of terrain color byte == | ==Usage of terrain color byte== | ||
Text is stored differently than any other element. Internally, ZZT repurposes the element's color byte to store character data instead: this allows the full range of characters to be encoded without having to allocate extra space (in the form of [[stats]]) for each tile. Since the color byte is occupied with other data, the actual color info is encoded by having different element IDs for each color. The result is that text is technically not just one element, but several. | Text is stored differently than any other element. Internally, ZZT repurposes the element's color byte to store character data instead: this allows the full range of characters to be encoded without having to allocate extra space (in the form of [[stats]]) for each tile. Since the color byte is occupied with other data, the actual color info is encoded by having different element IDs for each color. The result is that text is technically not just one element, but several. | ||
Line 31: | Line 31: | ||
*Overwriting text (using [[Put|#put]] or [[Become|#become]]) will sometimes result in [[STK]]-colored elements. This is because those commands always interpret the color byte as a color: if you #put a gem onto a blue text "Z" (ASCII code 0x5A), you will get a green-on-dark-purple gem (color code 0x5A). | *Overwriting text (using [[Put|#put]] or [[Become|#become]]) will sometimes result in [[STK]]-colored elements. This is because those commands always interpret the color byte as a color: if you #put a gem onto a blue text "Z" (ASCII code 0x5A), you will get a green-on-dark-purple gem (color code 0x5A). | ||
*Unlike most elements, it is impossible to get arbitrary text colors from [[Toolkit|toolkits]] or [[External editor|external editors]]. This is not a matter of ZZT's internal editor being restrictive, but rather a limit imposed by the file format and the in-memory representation. | *Unlike most elements, it is impossible to get arbitrary text colors from [[Toolkit|toolkits]] or [[External editor|external editors]]. This is not a matter of ZZT's internal editor being restrictive, but rather a limit imposed by the file format and the in-memory representation. | ||
Text is also the only element supported by the built-in editor that has no ZZT-OOP name: e.g., there is no way to change all text tiles to another element type. This may also be a side effect of text having a unique encoding. | Text is also the only element supported by the built-in editor that has no ZZT-OOP name: e.g., there is no way to change all text tiles to another element type. This may also be a side effect of text having a unique encoding. | ||
== Unassigned element IDs == | ==Unassigned element IDs== | ||
ZZT only officially supports the seven text colors which have assigned element IDs. However, it is possible to get a few additional colors by using IDs beyond the assigned range, as ZZT interprets all element IDs greater than 0x2E as text. The problem is that all these IDs are buggy because they cause ZZT to read past the end of its table of elements. Touching tiles with these IDs will crash ZZT, and many unassigned IDs will crash ZZT immediately, on the first [[tick]]. | ZZT only officially supports the seven text colors which have assigned element IDs. However, it is possible to get a few additional colors by using IDs beyond the assigned range, as ZZT interprets all element IDs greater than 0x2E as text. The problem is that all these IDs are buggy because they cause ZZT to read past the end of its table of elements. Touching tiles with these IDs will crash ZZT, and many unassigned IDs will crash ZZT immediately, on the first [[tick]]. | ||
Some known unassigned IDs and their text colors: | Some known unassigned IDs and their text colors: | ||
* 0x36: Blinking white on black | *0x36: Blinking white on black | ||
* 0x37: Blinking white on blue | *0x37: Blinking white on blue | ||
* 0x38: Blinking white on green | *0x38: Blinking white on green | ||
* 0x39: Blinking white on cyan | *0x39: Blinking white on cyan | ||
* 0x3A: Blinking white on red | *0x3A: Blinking white on red | ||
* 0x3B: Blinking white on purple | *0x3B: Blinking white on purple | ||
* 0x3C: Blinking white on brown | *0x3C: Blinking white on brown | ||
* 0x3D: Blinking white on light gray | *0x3D: Blinking white on light gray | ||
*0x45: White on light gray | |||
It is impossible to choose the text foreground color because ZZT hard-codes it to be white. This means there are only 16 possible color combinations: the 7 text colors built into ZZT, and the 9 produced by the unassigned IDs above. | |||
[[Category:Elements]] | [[Category:Elements]] |
Revision as of 07:40, 1 June 2020
Text | |
---|---|
Text can display any character, but color choices are limited | |
ZZT-OOP name | N/A |
Internal ID | Multiple, used to encode background color:
|
Character | Any (determined by tile's color byte) |
Default color | White foreground; element ID determines background |
Stats? | no |
Other traits | |
Effect on movement | wall |
Uses ZZT-OOP color names? | N/A |
Text is a terrain type that can have any of the 256 characters. Its intended use is for putting text labels on a board's terrain.
Text is the only element that can display any character without the overhead of using a stat, which makes them useful for ZZT art. However, artistic usage is somewhat hampered by the fact that text can only use a fixed set of color combinations: if you want to write a sentence on the screen in a custom color (e.g., black on light gray), the only way to do it is to
Text is also the only element supported by the built-in editor that has no ZZT-OOP name: e.g., there is no way to change all text tiles to another element type.
Usage of terrain color byte
Text is stored differently than any other element. Internally, ZZT repurposes the element's color byte to store character data instead: this allows the full range of characters to be encoded without having to allocate extra space (in the form of stats) for each tile. Since the color byte is occupied with other data, the actual color info is encoded by having different element IDs for each color. The result is that text is technically not just one element, but several.
Side effects from this roundabout encoding are apparent in a couple of places:
- Overwriting text (using #put or #become) will sometimes result in STK-colored elements. This is because those commands always interpret the color byte as a color: if you #put a gem onto a blue text "Z" (ASCII code 0x5A), you will get a green-on-dark-purple gem (color code 0x5A).
- Unlike most elements, it is impossible to get arbitrary text colors from toolkits or external editors. This is not a matter of ZZT's internal editor being restrictive, but rather a limit imposed by the file format and the in-memory representation.
Text is also the only element supported by the built-in editor that has no ZZT-OOP name: e.g., there is no way to change all text tiles to another element type. This may also be a side effect of text having a unique encoding.
Unassigned element IDs
ZZT only officially supports the seven text colors which have assigned element IDs. However, it is possible to get a few additional colors by using IDs beyond the assigned range, as ZZT interprets all element IDs greater than 0x2E as text. The problem is that all these IDs are buggy because they cause ZZT to read past the end of its table of elements. Touching tiles with these IDs will crash ZZT, and many unassigned IDs will crash ZZT immediately, on the first tick.
Some known unassigned IDs and their text colors:
- 0x36: Blinking white on black
- 0x37: Blinking white on blue
- 0x38: Blinking white on green
- 0x39: Blinking white on cyan
- 0x3A: Blinking white on red
- 0x3B: Blinking white on purple
- 0x3C: Blinking white on brown
- 0x3D: Blinking white on light gray
- 0x45: White on light gray
It is impossible to choose the text foreground color because ZZT hard-codes it to be white. This means there are only 16 possible color combinations: the 7 text colors built into ZZT, and the 9 produced by the unassigned IDs above.