Page 1 of 1

What is a nifty way to make your LOVE app restart?

Posted: Wed Sep 14, 2016 6:26 pm
by D0NM
What is a nifty way to make your LOVE app restart properly?
(Win / Linux / Mac OS)

I'm working on a screen res/ratio settings and dont want to
have deal with much of dynamical calculations. So.

Re: What is a nifty way to make your LOVE app restart?

Posted: Wed Sep 14, 2016 6:39 pm
by Plu
Do you mean restarting the game inside the running application, or do you mean quitting the whole thing and then starting it from scratch with a new resolution?

Re: What is a nifty way to make your LOVE app restart?

Posted: Wed Sep 14, 2016 6:49 pm
by D0NM
Plu wrote:Do you mean restarting the game inside the running application, or do you mean quitting the whole thing and then starting it from scratch with a new resolution?
I'd like to have "restarting inside the running application"
with the same effect as starting it from scratch.
To make the app re-read config.lua and init all the Love2d inner stuff.

Re: What is a nifty way to make your LOVE app restart?

Posted: Wed Sep 14, 2016 10:24 pm
by zorg
While, to my knowledge, calling love.load love.run manually to restart the game would be the preferred way, unless you also load in conf.lua manually yourself, beforehand, and parse the settings, it won't do that by itself.

Re: What is a nifty way to make your LOVE app restart?

Posted: Thu Sep 15, 2016 5:50 am
by alloyed
This is undocumented afaict but you can call love.init() to re-do the conf.lua part:
https://bitbucket.org/rude/love/src/88e ... ot.lua-331
To actually reload conf.lua so it reflects your changes, you'll first have to zero it out, like any other lua module, using

Code: Select all

package.loaded["conf"] = nil

Re: What is a nifty way to make your LOVE app restart?

Posted: Thu Sep 15, 2016 9:51 am
by D0NM
zorg, alloyed thank you!
I'll try it and watch over the memory usage and stuff.

Thank you. This is a good point to start.

Re: What is a nifty way to make your LOVE app restart?

Posted: Thu Sep 15, 2016 10:55 am
by kikito
If you are careful about where and when your game stores state, you could re-start it by just invoking love.load() manually. But this requires being really organized and strict with your code.

Re: What is a nifty way to make your LOVE app restart?

Posted: Thu Sep 15, 2016 11:17 am
by slime
LÖVE 0.10.2 will have the ability to call love.event.quit("restart") which will effectively do a full restart (including destroying the entire Lua instance and starting a new one). However if you just want to be able to change settings mid-game I recommend writing the game in such a way that you don't need to restart for the new settings to take effect. :)

Re: What is a nifty way to make your LOVE app restart?

Posted: Thu Sep 15, 2016 6:14 pm
by D0NM
slime wrote:LÖVE 0.10.2 will have the ability to call love.event.quit("restart") which will effectively do a full restart (including destroying the entire Lua instance and starting a new one). However if you just want to be able to change settings mid-game I recommend writing the game in such a way that you don't need to restart for the new settings to take effect. :)
))) So true.