Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | XenoN | |
Old Version | Published before Godot 3 was released. |
So … how to edit the variable from one node to be modified on the other node? Help me pleasee
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | XenoN | |
Old Version | Published before Godot 3 was released. |
So … how to edit the variable from one node to be modified on the other node? Help me pleasee
Reply From: | Warlaan |
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.