Text Codes & Enhancements
Text Codes and Enhancements
RPGReact provides a modern message system that supports both standard RPG Maker MZ text codes and new enhanced codes for richer UI elements.
Standard Text Codes
The following standard codes are supported and rendered natively by the React message window:
\V[n]
Replaced by the value of variable n.
\N[n]
Replaced by the name of actor n.
\P[n]
Replaced by the name of party member n (1-indexed).
\G
Replaced by the currency unit (e.g., Gold).
\C[n]
Changes the text color to index n (from the system palette).
\I[n]
Draws icon n inline with the text.
\{
Increases the font size by 12 pixels.
\}
Decreases the font size by 12 pixels.
\\
Replaced by the backslash character.
Enhanced Text Codes
We have introduced new codes that allow you to display the names of database items, weapons, and armors dynamically. These are rendered as specialized UI components:
\IT[id]
Renders the name of Item with the specified ID.
\IW[id]
Renders the name of Weapon with the specified ID.
\IA[id]
Renders the name of Armor with the specified ID.
These codes do more than just simple string replacement. They are passed as SpecialCode objects to the React renderer, allowing for specific CSS styling (e.g., .rpg-item, .rpg-weapon, .rpg-armor) or even custom tooltips in future updates.
Nested Variable References
One of the most powerful enhancements is the support for nested escape codes. You can use a variable reference as the ID for another code.
Example: \IT[\V[13]]
How it works:
The message system first resolves all variable tags (
\V[n]) recursively.If Variable #13 contains the value
5, the string becomes\IT[5].The
TypewriterandSpecialCodeRendererthen look up Item #5 and render its name.
This works for all codes that take an ID, including \N, \P, \C, \I, \IT, \IW, and \IA.
Implementation Details
Early Resolution: Variables are resolved using
gameMessage.convertEscapeCharacters()before the message is passed to theTypewriter. This allows for infinite nesting like\V[\V[\V[1]]].Styling: Rendered codes are wrapped in spans with specific classes:
.rpg-code: Base class for all special codes..rpg-var,.rpg-actor,.rpg-party,.rpg-currency: For standard substitutions..rpg-item,.rpg-weapon,.rpg-armor: For enhanced database lookups.
Typewriter Integration: The
Typewritercomponent correctly calculates the skip length for these multi-character escape sequences, ensuring a smooth typing effect without "ghost" characters appearing during the animation.
Last updated