+2 votes

Hello guys!
I have ugly code:

var explabel = get_parent().get_parent().get_parent().get_parent().get_parent().get_parent().get_node("CenterPanelContainer/CenterBoxContainer/ExperiencePanel/ExperienceBox/LabelValue")

It's work, but it's ugly! >.< my eyes bleeding whe i see it.

from this view:
enter image description here

HOW CAN I DO IT PERFECTLY BEAUTIFUL? ;D

THANK YOU VERY MUCH!

in Engine by (38 points)

2 Answers

+2 votes
Best answer

getparent().getparent().getparent().getparent().getparent().getparent().get_node("CenterPanelContainer/CenterBoxContainer/ExperiencePanel/ExperienceBox/LabelValue")

Holy shit my sides
I would suggest using a central script at the root of the scene with a variable referencing the desired node. eg:

onready var explabel = get_node("CenterPanelContainer/ExperiencePanel/ExperienceBox/LabelValue")

Then query from the "searching" node via:
get_parent("SceneRoot").explabel

by (164 points)
selected by
0 votes

One way is to add a script to the parent node of CenterPanelContainer and RightPanelContainer nodes, pass a reference to this parent to AdvantageB node when initializing and have a method in the parent node that returns the ExperienceBox/LabelValue

Another way is to declare a signal and emit it from AdvantageB node when experience label needs to be update it and and connect the experience node to listen to the signal events

by (95 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.