+2 votes

There are a lot of warnings like this generated regarding return values of functions which are never used. Should this be ignored or is there anything to do with this kind of warnings?

in Engine by (78 points)

3 Answers

+1 vote
assert(get_tree().change_scene("res://path/to/scene.tscn") == OK)
by (1,869 points)

Note that this breaks on release builds

+1 vote

You could also add a comment above the line

# warning-ignore:return_value_discarded
get_tree().change_scene("res://path/to/scene.tscn")

When you are in your gdscript file, in the lower right you will see a yellow exclamation.
If you click on that, it will show you the warnings in the file.
From there you can click "ignore" which will put that specific warning text above the line.

by (242 points)
+2 votes

the return value is an error code. if there is no error it returns 0

var error_code = get_tree().change_scene(scene)
if error_code != 0:
    print("ERROR: ", error_code)
by (85 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 [email protected] with your username.