Function call error Unexpected Token: Identifier

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Itention

Hello from germany,
im new @ godot and an absolute beginner getting this error…

Whats wrong with this?

Godot Function

:bust_in_silhouette: Reply From: kidscancode

This doesn’t work because you can’t call your function at the top level of the class. I assume you have an extends line at the top that you just didn’t copy and paste. You could call it when the program is run like this:

func _ready():
    my_function(12, 21)

But note that even then, you’re discarding the return value, so you’d probably want something more like:

func _ready():
    var c = my_function(12, 21)
    print(c)

I don’t know your level of programming experience, so If this doesn’t make sense to you, I strongly suggest that you start with a beginner-level coding tutorial - Python would be my recommendation.

If you do know how to code, but you’re just confused about Godot & GDScript, Step by step section of the official docs. There is a lot of important foundational material there.

Hi kidscancode. Btw great tutorials, thanks for that.
I did the sololearn phton course (50%) and know a lot php/css/html.
That really helped everything work fine now, thanks.

Itention | 2019-04-09 06:29