In the following script for a Label, if the property Use Temp Variable is true, the last character of the Label's text is removed every two seconds. If Use Temp Variable is false, no characters are removed.
Is this a bug? (Godot 3.5.1)
extends Label
export var use_temp_variable: bool = true
func _ready() -> void:
text = "This is a text string."
var timer: Timer = Timer.new()
add_child(timer)
timer.start(2.0)
# warning-ignore:return_value_discarded
timer.connect("timeout", self, "_on_Timer_timeout")
func _on_Timer_timeout() -> void:
print_debug("text=", text)
if use_temp_variable:
var s: String = text
s.erase(s.length() - 1, 1)
text = s
else:
text.erase(text.length() - 1, 1)
This example is self-contained. To try it, create a Label and attach the above script to it. Run the project and toggle the Use Temp Variable property in the Inspector. Observe the Label's content in the viewport or the output from the print_debug() statement.