Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | xiaojian |
Hello, so that’s my problem. The idea of the code is when in the scene “Send data” the user sends the name, points that he has won and if he has won or lost the game in general. But when I pass that data to the other scene (with a global variable). It keeps overwriting the first one, and skipping the second label. This is my code:
func _ready():
rellenarPuntuaciones()
func volverAlMenu():
escenaMenu = “res://Scenes/Menu.tscn”
get_tree().change_scene(escenaMenu)
func rellenarPuntuaciones():
if $Fondomenu/ColorRect/VBoxNicknames/Nickname.text.empty():
$Fondomenu/ColorRect/VBoxNicknames/Nickname.text = Player.nickname
$Fondomenu/ColorRect/VBoxPoints/Points.text = str(Player.points)
$Fondomenu/ColorRect/VBoxResult/Result.text = Player.result
elif nickname2Taken == $Fondomenu/ColorRect/VBoxNicknames/Nickname2.text.empty():
$Fondomenu/ColorRect/VBoxNicknames/Nickname2.text = Player.nickname
$Fondomenu/ColorRect/VBoxPoints/Points2.text = str(Player.points)
$Fondomenu/ColorRect/VBoxResult/Result2.text = Player.result
Hmmm… Different username, but seemingly the exact same question (and code) as this from yesterday…
Writing in multiple labels without overwriting the first one - Archive - Godot Forum
In the future, rather than opening a repeat question (and ignoring any input in the original), just continue the conversation in the original ticket. You can edit
and comment
in that ticket as necessary - keeping all related information in a single place…
jgodfrey | 2023-05-19 13:46
Yes, I know, he is my partner. We are doing a small final project on our class. It’s a videogame, sorry for the misunderstanding
xiaojian | 2023-05-19 14:17
As noted in the other instance of this question, it’s unclear how you intend the above code to interact with the global nickname storage. The code in question appears to (still) be called from _ready()
, meaning that it’ll only execute once, when the node containing the script is added to the scene tree.
Without more information (or access to the project itself), it’s difficult to provide more input.
jgodfrey | 2023-05-19 16:54