How to terminate a game with speicified exit code?

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

I mean the process exit code. Example from shell:

$ false; echo $?
1
$ true; echo $?
0

I only found quit() on SceneTree, but that doesn’t accept any parameters.

:bust_in_silhouette: Reply From: monnef

Oh, just found it: OS.set_exit_code(1).

I only found quit() on SceneTree, but that doesn’t accept any parameters.

quit() accepts an optional exit code parameter since Godot 3.2 :slight_smile:

Calinou | 2020-05-19 20:15

:bust_in_silhouette: Reply From: supper_raptor

you can use get_tree().quit(exit_code)
get_tree().quit(3) exit with exit code 3
get_tree().quit(-1) exit with exit code -1