0 votes

Hello! I am trying to make a scoreboard table using RichTextLabel.
There is my code:

func set_result(rows: Array) -> void:
$RichTextLabel.push_table(3)
for row in rows: # Add table values
    for key in row:
        $RichTextLabel.push_cell()
        $RichTextLabel.add_text(key)
        $RichTextLabel.pop()

I can see the table, but in the zero line, the text is superimposed on each other. How to fix it?

in Engine by (61 points)

1 Answer

+1 vote
Best answer

Your code seems to work as expected for me. I tested it like this:

func _ready():
    var a = [["a", "b", "c"], ["d", "e", "f"], ["g", "h", "i"], ["j", "k", "l"]]
    set_result(a)

func set_result(rows: Array) -> void:
    $RichTextLabel.push_table(3)
    for row in rows: # Add table values
        for key in row:
            $RichTextLabel.push_cell()
            $RichTextLabel.add_text(key)
            $RichTextLabel.pop()

That generates a table containing 4 rows (the 4 sub-arrays) and 3 columns. I don't see any overlapping text...

by (13,674 points)
selected by

Ok, you are right. But I think you did it with the default background color and RichTextLabel. I found that overlapping text is "shadow", so I just set Custom Colors -> Font Color Shadow with a transparent color and it works! Maybe you can suggest a better solution. Anyway, thanks!

Hmmm... Yeah, activating the shadow color does cause some strange results. Really, that feels like a bug to me, but I'm not familiar with the details of the RichTextLabel node so I'm not 100% sure.

However, rather than setting the shadow color to transparent, you can simply not use the shadow color by unchecking Custom Colors | Font Color Shadow. At least, that works as expected here...

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.