Godot Version
4.22
Question
I create a test scene that include background ColorRect, Timer and Santa node(this include some nodes and UI node, that have a Label node named “Best_int_label”. And i create an autoloading script “data” that have a code:
extends Node
var best_score = 0
var file
func _ready():
if FileAccess.file_exists(“data.txt”):
file = FileAccess.open(“data.txt”, FileAccess.READ)
best_score = int(file.get_as_text())
file.close()
new_best(best_score)
func _process(delta):
pass
func new_score(score):
if score > best_score:
new_best(score)
func new_best(score):
best_score = score
file = FileAccess.open(“data.txt”, FileAccess.WRITE)
file.store_line(str(best_score))
file.close()
#HERE I NEED TO CHANGE TEXT OF “test/santa/ui/best_int_label”
How i can change text of “test/santa/ui/best_int_label” at last line of this script? I cant do this with using “get_node(“test/santa/ui/best_int_label”)”, because godot give an error that node not found.
I want to make sure that when game opening, it reads data from “data.txt”. And when player set new best score, game save it to data.txt. Maybe i can do this in different way?
Thanks