Random beginner-question: bbcode a character's offset in a RichTextLabel

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By pferft

Happy new year everyone,

I managed to bbcode-tweak my RichTextLabel so that the first digit turns blue when a certain number of digits are entered:

var templateWriting = "[right][color=blue]{firstDigit}[/color]{remainingDigits}[/right]"

I can also make, for example, that first digit shake…

"[right][shake rate=15 level=20]{firstDigit}[/shake]{remainingDigits}[/right]"

This all works fine. But I can’t have both effects at the same time. I thought that should work like this:

"[right][color=blue][shake rate=15 level=20]{firstDigit}[/color][/shake]{remainingDigits}[/right]"

But this doesn’t seem to work. How could I achieve this?

LIKE THIS: [color] [shake] need to close in the right order [/shake] [/color]. Careful not to mix them up.

However, what my question is aiming for in the first place: how can I have that first digit to be set a little higher than the others? I was wondering if that could be done via “offset”, maybe something like [offset = Vector2 (0, 20)], but I can’t really figure it out. Or maybe this could be done with the RichTextLabel’s custom fonts’ property “extra_spacing_char”?
Any help is mich appreciated!

(Weirdly enough, setting the shake rate to 0 and the level to e. g. 80 clearly changes the position of the digit (without shaking around, obviously). But there must be a proper way to do this…)

Like this:

[offset x=0 y=20]  

Code would be something like this

extends RichTextEffect
class_name RichTextOffset

var bbcode = "offset"

func _process_custom_fx(char_fx):
	var x = char_fx.env.get("x", 0)
	var y = char_fx.env.get("y", 0)
	char_fx.offset = Vector2(x,y)

	return true

The according video:

Thanks to art_critique on reddit!

:bust_in_silhouette: Reply From: jgodfrey

For the mutiple effects example above, your color and shake tags are nested incorrectly. This should work show both effects at the same time.

[right][color=blue][shake rate=15 level=20]1[/shake][/color]23456[/right]

For the vertical position, I’d guess you could do that via a custom effect, and the position property. See near the bottom of this page:

Errr… Wait. Either I didn’t read your question closely enough or it’s been updated since. Either way, the code you posted does indeed work as you want. With that code, and the setup indicated in the video you linked, this BBCODE text works as intended:

[offset x=0 y=-5]1[/offset]2345

That offsets the 1 digit up by 5 pixels…

jgodfrey | 2021-01-05 20:11

The order of opening and closing tags is indeed the point. And the offset position tag is exactly what I was looking for.

Thanks for your help!
(Yes, I added those edits in the meantime. Sometimes things go quickly! : )

pferft | 2021-01-05 20:19