0 votes

I'm trying to access a node nested inside an instance scene created at runtime.

I got at the point where I can manually write the path to the node like this.

for item in slot.get_children():
        if item.is_in_group("ItemsG"):

Is there a better way to write or doing this in general? Do I keep doing as I'm doing adding strings together this way?

in Engine by (399 points)
edited by

1 Answer

+2 votes
Best answer

For each node that is a member of the ItemsG group, if they do not already have a script attached, attach a script and define a member variable that references the label node

# ItemsG.gd

onready var amount_label  = $Fruit/Amount


for item in slot.get_children():
    if item.is_in_group("ItemsG"):
by (1,650 points)
selected by
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.