The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Hi everyone,

I have two templates set up in a RichTextLabel:

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

var templateGap = "[right][offset x=-10 y=0]{firstDigit}[/offset]{remainingDigits}[/right]"

In a function then accordingly:

bbcode_text = templateAlwaysAllRight.format({ "alwaysAllRight" : text })

bbcode_text = templateGap.format({ "firstDigit": text[0]}, {"remainingDigits": text.substr(1)})

The first one works wonderfully. But the second one (supposed to separate the first digit a bit from the rest) doesn't, instead it actually displays "[offset x=-10 y=0]{firstDigit}[/offset]{remainingDigits}" directly in the label. It does right-align though!

Any idea what I am missing here?

Godot version 3.3
in Engine by (525 points)

1 Answer

0 votes
Best answer

I believe it's with your parameter in the second one.
In your example you are providing 2 parameters (dictionaries) instead of one dictionary with two elements.

Try this:

bbcode_text = templateGap.format({ "firstDigit": text[0], "remainingDigits": text.substr(1)})
by (244 points)
selected by

Although I'm positive that you are right, unfortunately this still doesn't solve the issue. For whatever reason the format-text still appears in the label. Any other hint is much appreciated.

Ok, I checked this out in Godot itself this time and got it working.

offset does not exist as a bbcode tag, but can be implemented as a custom tag.

I followed the code from this post

You can see a code file for "RichTextOffset" in that post.

Afterwards on your richtextlabel you have to add this extra tag.
In the inspector find the "custom effects" and add the Richtextoffset.

That should do it.

It's rather funny that you linked my own post from over a year ago, isn't it? So technically I should have been able to make things work, but for whatever reason this time I wasn't, so there must be something else going on. I'll find out, thanks for your help!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.