0 votes

Hi everyone,

my Label get's the digit-entries from another Label and replaces them with *s.

var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]

func _on_aLabel_labelNotEmpty(): # triggers on each entry

    text = get_node(a_label).text.replace(0, "*")
    text = get_node(a_label).text.replace(1, "*")
    text = get_node(a_label).text.replace(2, "*")

This works for the last number, 2 in this case, but not for the others before.

Putting some yield time in between the lines shows that actually on each entry the whole sequence is being worked through. However, after changing the number to * it changes back to the digit with the next one in line...

How can the * be kept once replaced?
Or is there a more direct way to have digits replaced with * generally in the first place? (I bet!)

Godot version 3.2.3
in Engine by (464 points)

Well, it appears there were just some " " missing. This works:

text = text.replace("0", "*")

text = text.replace("1", "*")

text = text.replace("2", "*")

text = text.replace("3", "*")


And that's it. I'm sure RegEx could spare me some lines, but this does the trick for my little project.

1 Answer

0 votes
by (8,155 points)
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.