+1 vote

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 (75 points)

3 Answers

0 votes
assert(get_tree().change_scene("res://path/to/scene.tscn") == OK)
by (1,667 points)

Note that this breaks on release builds

+1 vote

You could also add a comment above the line

# warning-ignore:return_value_discarded

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 (114 points)
+1 vote

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 (83 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.