Auto close Spring on game end.

Auto close Spring on game end.

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

User avatar
TechnoTone
Posts: 165
Joined: 23 Aug 2005, 22:02

Auto close Spring on game end.

Post by TechnoTone »

Is it possible for LUA to detect when the a game is over and automatically quit Spring? Or is there another way to get Spring to quit automatically without using LUA that I don't know about?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

Yes, using commandline arguments. (First line for windows, second for linux.)

Code: Select all

/quit <seconds>
--quit=<seconds>
Replace <seconds> with a number of seconds.

This quits the game after either seconds wallclocktime have passed or as soon as the game ends, whichever comes first.
User avatar
TechnoTone
Posts: 165
Joined: 23 Aug 2005, 22:02

Post by TechnoTone »

Thanks, but where do I use this argument. I've tried it with TASClient.exe but it made no difference. If it's for Spring.exe then how do I get the lobby client to include it?
User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Post by Licho »

Lol I didn't know, and went to some bumpy road with autohost to achieve just that :)
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Post by Dragon45 »

those lines should be integrated into settings.exe tbh (perhaps with a timeout period so that it only autoquits after like, 7 seconds or so, to give people a chance to view endgame stats)
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

No, if anything this should be integrated into the startscript.

This setting belongs semantically to one game, not to the settings of the entire engine.
User avatar
TechnoTone
Posts: 165
Joined: 23 Aug 2005, 22:02

Post by TechnoTone »

So am I to understand that there's no way I can do this at the moment without LUA?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

Well, you could probably rename spring.exe and make a hook spring.exe that calls the renamed spring.exe with the /quit argument in addition to all other arguments passed to it :-)

But there is not an easy way to pass extra argument via TASClient, no. I don't know about other lobbies but I have not seen this feature in any of them yet.
Regret
Posts: 2086
Joined: 18 Aug 2007, 19:04

Post by Regret »

Code: Select all

function widget:GetInfo()
  return {
    name      = "Quit game on GameOver",
    desc      = "Quit game on GameOver",
    author    = "Regret",
    date      = "Sep 12, 2007",
    license   = "GNU GPL, v2 or later",
    layer     = 0,
    enabled   = false  --  loaded by default?
  }
end

function widget:GameOver()
	Spring.SendCommands({"quit"})
end
Place it in a new .lua file, put to your widgets directory, activate.
User avatar
TechnoTone
Posts: 165
Joined: 23 Aug 2005, 22:02

Post by TechnoTone »

Thanks Regret!

Thanks too to everyone else for your input.
Smiff
Posts: 123
Joined: 03 Oct 2007, 12:54

Post by Smiff »

is it possible to put in a delay between game end and quit please? say 60 seconds, so you've time to read the scoreboard. i don't know any Lua, but this widget is a great idea if you've got kids who are too (something) to close their games.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Post by Forboding Angel »

This would play absolute havoc with modders doing offline testing...
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Post by FLOZi »

Forboding Angel wrote:This would play absolute havoc with modders doing offline testing...
...which is why they would disable it.
User avatar
TechnoTone
Posts: 165
Joined: 23 Aug 2005, 22:02

Post by TechnoTone »

What are you talking about FA? If you don't want it to auto-quit then you disable the widget!


Smiff, yes, that should be pretty straight forward. When I get some time I'll add a (configurable) delay.
User avatar
Evil4Zerggin
Posts: 557
Joined: 16 May 2007, 06:34

Re: Auto close Spring on game end.

Post by Evil4Zerggin »

Sorry for the ress, but:

Funny enough, I came up with the same idea and wrote a widget, then Google Frog informed me that you had coded this. In any case, here's my version: http://trac.caspring.org/browser/trunk/ ... toquit.lua

It's a little more elaborate: it doesn't quit immediately at game end. Instead, if the user does not click anywhere within 10s it exits.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Auto close Spring on game end.

Post by zwzsg »

I find it's better when a simple mouse movement, instead of a mouseclick, cancel the autoquit. So I edited Evil4Zerggin's widget:
Attachments
autoquit.lua
(1.67 KiB) Downloaded 41 times
User avatar
Evil4Zerggin
Posts: 557
Joined: 16 May 2007, 06:34

Re: Auto close Spring on game end.

Post by Evil4Zerggin »

Yeah, I tried widget:MouseMove but that didn't seem to work. Didn't think of doing it that way.
BaNa
Posts: 1562
Joined: 09 Sep 2007, 21:05

Re: Auto close Spring on game end.

Post by BaNa »

I've been using this and it is very nice, thanks!

lets me spec games in a row without babysitting the pc
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Auto close Spring on game end.

Post by Forboding Angel »

Sorry I hadn't read the widget stuffs when I said that. I was mainly thinking in regards to using script for it.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Auto close Spring on game end.

Post by zwzsg »

In my edit, all you need to disable it is to wave the mouse after game is over. If you are testing a mod, I assume you are sitting in front of PC, mouse in hand, and as soon as you'll see the game over screen, by reflex, you'll grab the window to pull it away, and so disable the autoquit without even having to think about it. If your mouse stays immobile for more than 5 seconds, then it's safe to assume your are AFK, and so it autoquits for you.
Post Reply

Return to “Lua Scripts”