I'm working on a multiplayer game, and I'm currently looking into a way to prepare the client for a shutdown with Alt-F4 or ⌘Q if a user tries to midgame. As it stands, both sides work, however if a player quits, it currently leaves the player on the server for a few brief moments.
I've tried the usual keypress routines but they don't seem to beat the quit command (at least on macOS). How do I get LÖVE to run custom commands or a function as soon as LÖVE is closed?
Detecting/interrupting when a user is quitting the program
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 5
- Joined: Sat Jul 01, 2017 5:58 pm
- Contact:
Detecting/interrupting when a user is quitting the program
Code: Select all
room = {"Saskatoon","Poulsbo","Benettsville","Palmyra"}
Chicago = not Chicago
- slime
- Solid Snayke
- Posts: 3170
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Detecting/interrupting when a user is quitting the program
You can use the love.quit callback which is called when the user quits the game via command-Q etc. It also has the ability to prevent the game from quitting, so you can use it to wait for the client to successfully send a disconnect event to the server, for example (and then use love.event.quit to quit for real once that's complete).
-
- Prole
- Posts: 5
- Joined: Sat Jul 01, 2017 5:58 pm
- Contact:
Re: Detecting/interrupting when a user is quitting the program
Excellent, thank you. :-)
I'm now worried to see what else I missed on the love function callbacks page!
I'm now worried to see what else I missed on the love function callbacks page!
Code: Select all
room = {"Saskatoon","Poulsbo","Benettsville","Palmyra"}
Chicago = not Chicago
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 5 guests