![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Frenggie |
Hey. I am nearly to a mental breakdown because of this stupid label.
I am processing which character the player is talking to and the name of the character is then displayed as the labels text.
The problem is, that the label doesn’t replace the characters name with the new one whenever the following function is called. It adds it to the existing text. For example: At the first call, the labels text displays the characters name and on the second call it doesnt set the entire text new, but it just adds the new text to the old one so that I have the same name two times in the labels text.
I hope you understand my problem now.
Code:
onready var title = get_parent().get_node("HUD/DialogBox/Speaker") # label
func on_talking(with_who):
get_parent().get_node("HUD/DialogBox").visible = true
print("Talking to someone")
if len(title.text) > 0:
title.text = ""
title.text = format_name(with_who) # format_name only removes "_"
else:
title.text = format_name(with_who)
# some more stuff not related to the label down here
This does sound very frustrating, since the code you’ve provided seems to me to do what you (and I) expect and want. I think we need more of your project to help diagnose. Can you share it somewhere?
DDoop | 2020-06-27 21:30
I am sorry but I cannot post the project.
But if it helps diagnosing the problem… there is nothing else which is accessing the labels text property. The function I wrote in my question is in an event_handler.gd script which is running as a child of the player and is called by a signal from the player.
Could it be that Godot is processing common Labels differently in version 3.2.2 ? I am using the steam version.
Thanks for the answer.
Frenggie | 2020-06-28 00:13
I am using 3.2.2 on Mac and having the same issue with Label Node where I have the following code
if playername == "Player1":
statelabel.text = "Player 1"
else:
statelabel.text = "Player 2"
The Label shows the 1 and 2 characters overlapping each other ie. the rendered text area is not cleared properly.
Note. I have the same issue with the RichTextLabel
Looks like a 3.2.2 bug to me
adxsoft | 2020-08-05 15:31
Hi adxsoft, please make another question for your issue as the OP has marked this as resolved.
DDoop | 2020-08-05 20:08