Linux Launcher assistance

General discussion about LÖVE, Lua, game development, puns, and unicorns.
bajinaji
Prole
Posts: 3
Joined: Sat Oct 29, 2016 7:20 am

Linux Launcher assistance

Post by bajinaji »

Hey guys,

new to Love, new to Linux, not new to development.

I'm attempting to make a simple graphical launcher that runs an emulator to launch the given rom.

I've created the launcher interface, no problem, but I'm struggling (perhaps with Linux) as to how to exit the launcher, launch the emulator, then re-launch the launcher.

Details:
It's actually a Raspberry Pi 3 with stock OS running from the command line only. NO X. Using SDL for Love and the emulator.

Currently I'm called os.execute to launch the emulator. This line runs, but until I actually shut down the launcher it doesn't run the emulator.

Cheers for any assistance, and apologies if I have not given appropriate detail, please ask for any missing aspects.

Rob
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: Linux Launcher assistance

Post by pgimeno »

Hm, I can't reproduce. Maybe you mean that until you shut down the emulator, the launcher doesn't resume execution? Yeah, Lua is very limited. You can't fork. All you can do is launch a new thread and run os.execute() from it, so it doesn't stop the main thread.

Edit: for example:

Code: Select all

love.thread.newThread("os.execute('mess -window spectrum')\n"):start()
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Linux Launcher assistance

Post by Nixola »

Maybe you can use [manual]io.popen[/manual]?
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: Linux Launcher assistance

Post by pgimeno »

Oops, I stand corrected. io.popen does indeed fork. Problem is that it doesn't let the program terminate until the children have all finished.
bajinaji
Prole
Posts: 3
Joined: Sat Oct 29, 2016 7:20 am

Re: Linux Launcher assistance

Post by bajinaji »

Thanks for the assistance guys.

To be a little clearer ...

I cannot launch the emulator with a command within love that will either "suspend" my executing launcher, or shutdown the launcher, run the emulator, and when the emulator is exited, return to my launcher.

I tried using newThread, but to some degree it appears to act in a similar fashion to pure os.execute, in that when I shut down the launcher, the thread in the background comes to the fore and is clearly running.
I, however, need to have the thread or whatever instantly made the core running application on request, and then have it shutdown when the emulator is closed.
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: Linux Launcher assistance

Post by pgimeno »

I still don't understand. When I write a main.lua like this:

Code: Select all

os.execute('mess spectrum -window')
the launcher is not just "suspended", it is SUSPENDED. As in, the window doesn't even refresh. When I close the emulator, execution of the launcher resumes (I get a black window that I can then close). Maybe that's not what you're observing, and you want something like Python's Popen.wait(). https://docs.python.org/2/library/subpr ... en-objects

Well, I may be wrong again, but I don't think such thing exists in Lua.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Linux Launcher assistance

Post by Nixola »

I think you can use read for the same purpose somehow; I'd have to check some code of mine to be sure and I can't before ~18h.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Linux Launcher assistance

Post by Positive07 »

So if I understand correctly the behaviour you need is:

Run LÖVE program -> Execute emulator -> User closes emulator -> Shutdown LÖVE program automatically

Then you can call [manual]io.popen[/manual], wait for the process to finish and then calling [wiki]love.event.quit[/wiki]

If you want this instead:

Run LÖVE program -> Execute emulator -> Shutdown LÖVE program automatically -> User closes emulator

You can use [manual]os.execute[/manual] which you can make non-blocking by prepending "&" in Linux or "start" in Windows to your command (I took this from the Lua wiki), and then calling [wiki]love.event.quit[/wiki]
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
Rucikir
Party member
Posts: 129
Joined: Tue Nov 05, 2013 6:33 pm

Re: Linux Launcher assistance

Post by Rucikir »

Positive07 wrote: You can use [manual]os.execute[/manual] which you can make non-blocking by prepending "&" in Linux or "start" in Windows to your command (I took this from the Lua wiki), and then calling [wiki]love.event.quit[/wiki]
You have to append "&", not prepend it, like a shell command :)
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: Linux Launcher assistance

Post by pgimeno »

Nixola wrote:I think you can use read for the same purpose somehow; I'd have to check some code of mine to be sure and I can't before ~18h.
Looks like you're right. This did it for me:

Code: Select all

io.popen('mess spectrum -window', 'r'):read("*a")
love.event.quit()
I don't know if it will work the same on Windows.
Post Reply

Who is online

Users browsing this forum: No registered users and 219 guests