The function 'change_scene()' returns a value, but this value is never used. Can we ignore this?

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

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?

:bust_in_silhouette: Reply From: rakkarage
assert(get_tree().change_scene("res://path/to/scene.tscn") == OK)

Note that this breaks on release builds

Mariothedog | 2021-02-28 18:52

:bust_in_silhouette: Reply From: aipie

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.

:bust_in_silhouette: Reply From: ArthurER

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)