0 votes

I know that to capture "quit request" I can use the _notification and the constant NOTIFICATIONWMQUIT_REQUEST. This works fine when the game is running normally.

The problem is that I'm running the project from command line like this:

%godot% -d -s server/main.gd --no-window

I can't capture the quit request when running from the cmd, I've tried to use the _notification but it doesn't work. The only way I can capture it is when I'm running with the -d option, then I press Ctrl+C and type q. But I can't run the server in debug mode in production.

I need a way to execute a function when the console is closing (either using the X or using Ctrl+C).

Godot version 3.4.3
in Engine by (254 points)

I don't know how to do it from Windows' command prompt. But in Bash (on Unix-like OSes), programs have exit codes, and so a script can check for certain exit codes.

Please log in or register to answer this question.

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.