0 votes

Hi, so basically I am trying to call a function in my code for loading, (extremely simple, right?), but for some reason it's not long enough to be called?

func _pressed():
load()

func load():

^this is the func I am trying to call

in Engine by (12 points)

What does "not long enough to be called" mean? What actual problem are you having? How about showing your whole script? Please provide more information about your setup.

2 Answers

0 votes

Not sure what "not long enough to be called" means here. But could your problem be that load is a reserved function name?

https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_basics.html#classes-as-resources

Try calling your function something else.

by (388 points)
0 votes

Assuming it's not a copy/paste error, your script above is invalid syntax. The indentation is incorrect. Try

func _pressed():
    load()

func load():
    pass

EDIT: Also, as Tim Martin alluded to in another answer, you should generally shy away from shadowing built in functions and member variables.

by (104 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 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.