Open Mystievous opened 3 months ago
Why is there no closing }
bracket? It hurts readability with no separator between the color and the text.
Plus, if you parsed for a closing bracket you could then remove the length check and support other inputs such as 3-char hex (e.g. writing {#FFF}
would be evaluated the same as {#FFFFFF}
.
I agree with both points about readability and supporting more than just 6-char hex. However, I believe using a closing brace would require changing the existing convention set by some of the other features of the tell command, where {
is used as a "formatting start" character rather than an actual open brace that's meant to be closed.
You can see all of the already existing formatting symbols using this in the comments of the tellraw.py
file
{C for color
{U for underline, {u to exit underline, same for {D bold, {S strikethrough and {I italic
{- to clear formatting
...
So with the latest cbscript, the following should print an italicized gray "Hello", and a non-italics blue "World!"
function test_tell()
tell @a "{I{wHello{i {BWorld!"
end
I tried to keep my addition consistent with this while still allowing more freedom with the colors.
Fair enough for consistency, but now I think that all of them should be changed to have a closing bracket. because {ufoo
is similarly difficult for readability.
Out of scope for this PR, but there can just be a helper method in the parser somewhere to get all tokens within a pair of curly braces that all of the tell
format tags can share (with sanity checks for if it hits a newline or EOF token). This would standardize the parsing for all of them going forwards, so each format tag isn't rolling its own parser.
Text components in game support custom hex colors in addition to the specific named ones.
This PR adds support for that to the parsing for
tell
.Examples: