Text: Difference between revisions

From Wiki of ZZT
Jump to navigation Jump to search
(Fix sentence fragment)
m (byte)
 
(One intermediate revision by one other user not shown)
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
* {{Byte|47}}: Blue
* 0x30: Green
* {{Byte|48}}: Green
* 0x31: Cyan
* {{Byte|49}}: Cyan
* 0x32: Red
* {{Byte|50}}: Red
* 0x33: Purple
* {{Byte|51}}: Purple
* 0x34: Brown
* {{Byte|52}}: Brown
* 0x35: Black
* {{Byte|53}}: 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 39: Line 39:
Some known unassigned IDs and their text colors:
Some known unassigned IDs and their text colors:


*0x36: {{ColorSwatch|blinking|fg=white|bg=black}}
*{{Byte|54}}: {{ColorSwatch|blinking|fg=white|bg=black}}
*0x37: {{ColorSwatch|blinking|fg=white|bg=dark blue}}
*{{Byte|55}}: {{ColorSwatch|blinking|fg=white|bg=dark blue}}
*0x38: {{ColorSwatch|blinking|fg=white|bg=dark green}}
*{{Byte|56}}: {{ColorSwatch|blinking|fg=white|bg=dark green}}
*0x39: {{ColorSwatch|blinking|fg=white|bg=dark cyan}}
*{{Byte|57}}: {{ColorSwatch|blinking|fg=white|bg=dark cyan}}
*0x3A: {{ColorSwatch|blinking|fg=white|bg=dark red}}
*{{Byte|58}}: {{ColorSwatch|blinking|fg=white|bg=dark red}}
*0x3B: {{ColorSwatch|blinking|fg=white|bg=dark purple}}
*{{Byte|59}}: {{ColorSwatch|blinking|fg=white|bg=dark purple}}
*0x3C: {{ColorSwatch|blinking|fg=white|bg=dark brown}}
*{{Byte|60}}: {{ColorSwatch|blinking|fg=white|bg=dark brown}}
*0x3D: {{ColorSwatch|blinking|fg=white|bg=light gray}}
*{{Byte|61}}: {{ColorSwatch|blinking|fg=white|bg=light gray}}
*0x45: {{ColorSwatch|fg=white|bg=light gray}}
*{{Byte|69}}: {{ColorSwatch|fg=white|bg=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.
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.
{{ElementsNavbox}}
[[Category:Elements]]
[[Category:Elements]]

Latest revision as of 19:20, 13 February 2021

Text
Text-example.png
Text can display any character, but color choices are limited
ZZT-OOP nameN/A
Internal IDMultiple, used to encode background color:
  • 47 (0x2F): Blue
  • 48 (0x30): Green
  • 49 (0x31): Cyan
  • 50 (0x32): Red
  • 51 (0x33): Purple
  • 52 (0x34): Brown
  • 53 (0x35): Black
CharacterAny (determined by tile's color byte)
Default colorWhite foreground; element ID determines background
Stats?no
Other traits
Effect on movementwall
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 use objects.

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:

  • 54 (0x36): blinking white on black (0x8F)
  • 55 (0x37): blinking white on dark blue (0x9F)
  • 56 (0x38): blinking white on dark green (0xAF)
  • 57 (0x39): blinking white on dark cyan (0xBF)
  • 58 (0x3A): blinking white on dark red (0xCF)
  • 59 (0x3B): blinking white on dark purple (0xDF)
  • 60 (0x3C): blinking white on dark brown (0xEF)
  • 61 (0x3D): blinking white on light gray (0xFF)
  • 69 (0x45): white on light gray (0x7F)

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.