+1 vote

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

So ... how to edit the variable from one node to be modified on the other node? Help me pleasee

in Engine by (13 points)

1 Answer

+1 vote

Godot is strictly object oriented. When you define a var it becomes part of the object that the script is attached to. So when you access pts_rest from within the first script you are looking for the pts_rest-value in the first RichTextLabel and when you are doing it from within the second one you won't find it since that one doesn't have a var called pts_rest.

You need to get a reference to the first RichTextLabel in order to access the variable. The easiest way to do so is to use get_node(). In your case that's ok, since all nodes are part of the same scene.

By the way I would recommend moving the code into a script that is attached to the base node of the scene (the one called "TextureFrame"). After all you are programming a new complex control, not a collection of smart buttons. It's not really the RichTextBox's job to know how many points are left, that's something the whole control should take care of.

by (1,120 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 webmaster@godotengine.org with your username.