game development - Godot 4.3 - Setter from another script doesn't update label - Stack Overflow

admin2025-05-02  1

I am trying to change the text of a Richtextlabel from a different script using a setter and adding to that variable but when I do it, the function is called but the label doesn't update.

The setter code is:

var money : int:
    set = set_money
    
func set_money(LT):
    money = LT
    money_format()

(Money format just takes the number and adds commas when necessary) I am using this code to test the label:

func _unhandled_input(event):
    if event is InputEventKey:
        if event.pressed and event.keycode == KEY_A:
            MoneyText.money += 10

The richtextlabel is only visibly updated when the code is inside the same script despite the script being global. Also, there is a print statement inside money_format() that goes off every time I press the key "A" no matter where the code is, but the label still isn't updated.

转载请注明原文地址:http://www.anycun.com/QandA/1746136706a92080.html