Learning step by step » Scripting. Get Node error

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ninku
:warning: Old Version Published before Godot 3 was released.

Hi all, I am new to GoDot and I am 3D modeler. I have no experience with scripting etc. So I was following this tutorial. Step by Step > scripting.
http://docs.godotengine.org/en/latest/tutorials/step_by_step/scripting.html

And I got an error. The solution might be simple but I am not sure whats going on…
I get an error for this code [ get_node(“Button”) ]. The button is a child of Panel.

link to image > http://oi64.tinypic.com/23jmqtg.jpg

:bust_in_silhouette: Reply From: jospic

Because there is no method after get_node and the statement is out of “member functions” ( _ready, _process, _fixed_process, etc.)

Sorry, What do you mean by no method ?
I don’t have any knowledge of programming etc.

Ninku | 2016-05-25 09:25

It depends on what you wanted to do with the button… For example, use the function .set_pos(x, y) to place it at a certain point , and so on.

jospic | 2016-05-25 10:02

Thanks for the help.
Ahh I see. So I somehow managed to fix it. by deleting
get_node(“Button”) and func _ready():

So now it looks like this.

member variables here, example:

var a=2

var b=“textvar”

func _on_button_pressed():
get_node(“Label”).set_text(“HELLO!”)

func _ready():
get_node(“Button”).connect(“pressed”,self,“_on_button_pressed”)
[# Called every time the node is added to the scene.
# Initialization here ]

After I got this to work, I realized the answer was on that tutorial page. I am just not sure what these things are used for… But i left them there since its part of the tutorial.

[# Called every time the node is added to the scene.
# Initialization here ]
# member variables here, example:
[# var a=2]
[# var b=“textvar”]

Ninku | 2016-05-25 10:21