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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

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

Post 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.
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

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

Post 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?
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

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

Post 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.
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

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

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
alloyed
Citizen
Posts: 80
Joined: Thu May 28, 2015 8:45 pm
Contact:

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

Post 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
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

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

Post 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.
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

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

Post 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.
When I write def I mean function.
User avatar
slime
Solid Snayke
Posts: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

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

Post 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. :)
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

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

Post 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.
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests