Random beginner-question: Bb Code stops working at input

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

Hi everyone,

I have a RichTextLabel set up including:

export (NodePath) var pre_comma_digits


	var leftandrightofcomma = text.split(",", true, 1)
	get_node(pre_comma_digits).text = leftandrightofcomma[0]

So whenever I put some numbers in, they appear correctly in my PreCommaDigits-RichTextLabel as well. (The post-comma digits appear in another Label…)

With Bb Code I’d like these numbers to be aligned right, so within PreCommaDigits I coded:

extends RichTextLabel

var templateAlwaysAllRight = "[right]{content_to_align}[/right]"

func _ready():

	var the_numbers = self.text 
	bbcode_text = templateAlwaysAllRight.format({ "content_to_align": the_numbers })

I wrote “PRE” in the Bb Code textfield in the editor and this really is right-aligned at start. However, as soon as I enter numbers, they are displayed left aligned.

I tried things like



label.bbcode_text =  "[right]{replaceThis}[/right]"
label.bbcode_text = label.bbcode_text.format({"replaceThis":self.text})

and alike but all to no avail.
I’m not sure why this happens, but I assume I’d somehow need to get the “dynamically entered” numbers into a variable to be put into the right place then.

How could that be done? Any suggestions are much appreciated!

:bust_in_silhouette: Reply From: exuin

I’m not 100% sure if this is the issue, but

get_node(pre_comma_digits).text = leftandrightofcomma[0]

sets the text of pre_comma_digits and not the bbcode text, so maybe that’s the issue?