Opened 8 years ago

Closed 8 years ago

#807 closed enhancement (no change required)

Spring restarter debug widget

Reported by: beherith Owned by:
Priority: trivial Milestone:
Component: BAR Version:
Keywords: Cc:


I would like to bind a key to just restart Spring with the same script. Is this even possible?

Change History (9)

comment:1 by Bluestone, 8 years ago

It depends:

If you mean "with the same script as it was started from" then, no, because there is no reliable way of finding what/where the starting script was.

If you mean "with the same script, and i have it here in this .txt file", then yes!

Last edited 8 years ago by Bluestone (previous) (diff)

comment:2 by beherith, 8 years ago

Yes, with the default script.txt :)

comment:3 by Bluestone, 8 years ago

What do you mean by default?

There is no requirement for the lobby to place the script.txt in any particular place, or even to generate a script.txt file (latest dev spring allows connection to an online game without even having a lobby).

Last edited 8 years ago by Bluestone (previous) (diff)

comment:4 by Funkencool, 8 years ago

Doesn't spring create a temporary _script.txt that is a copy of the script.txt used to start, or is that the lobby?

comment:5 by Bluestone, 8 years ago

I think it will only do that if Spring is actually launched via a script (which was once always the case). But I'm not sure - you'd have to check the new "join a running game using only ip+port" behaviour.

If the _script.txt exists in a known location then Spring.Restart can be used with command line args, instead of having the script as a lua string.

Last edited 8 years ago by Bluestone (previous) (diff)

comment:6 by beherith, 8 years ago

--This seems to crash spring for me:

function widget:GetInfo()
   return {
      name      = "Restart Spring",
      desc      = "type /luaui restart to relaunch spring!",
      author    = "Beherith",
      version   = "v1.0",
      date      = "2014",
      license   = "GNU GPL, v3 or later",
      layer     = 200,
      enabled   = true,

function widget:Initialize()
	Spring.SendCommands("bind ctrl+alt+r luaui restart")

function Restart()
gametype=]] .. Game.gameName .. [[;
mapname=]] .. Game.mapName .. [[;

function widget:TextCommand(command)
	if (string.find(command, "restart") == 1) then Restart() end

Last edited 8 years ago by beherith (previous) (diff)

comment:7 by Bluestone, 8 years ago

The putting the script.txt into its own file and calling Spring.Restart with that (it has two forms for its args). Trying to use it with a script in a string has been on/off buggy for as long as I can remember.

comment:8 by Funkencool, 8 years ago

I've messed around with it before and I could never get passing as string to work. Granted I only tried in a few versions. In the end saving as file first is probably a good idea anyway, then there's a backup in case of a failed launch, etc..

comment:9 by Bluestone, 8 years ago

Resolution: no change required
Status: newclosed

We will soon have Spring.Reload("startScript").

Note: See TracTickets for help on using tickets.