Opened 6 years ago

Closed 6 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:

Description

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, 6 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 6 years ago by Bluestone (previous) (diff)

comment:2 by beherith, 6 years ago

Yes, with the default script.txt :)

comment:3 by Bluestone, 6 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 6 years ago by Bluestone (previous) (diff)

comment:4 by Funkencool, 6 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, 6 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 6 years ago by Bluestone (previous) (diff)

comment:6 by beherith, 6 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,
   }
end
   

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

function Restart()
	Spring.Restart("",([[
[game]
{
[ai0]
{
host=0;
name=Enemy;
shortname=NullAI;
team=1;
version=0.1;
}
[allyteam0]
{
numallies=0;
}
[allyteam1]
{
numallies=0;
}
[modoptions]
{
maxspeed=20;
}
[player0]
{
name=UnnamedPlayer;
team=0;
}
[team0]
{
allyteam=0;
teamleader=0;
}
[team1]
{
allyteam=1;
teamleader=0;
}
gametype=]] .. Game.gameName .. [[;
ishost=1;
mapname=]] .. Game.mapName .. [[;
myplayername=UnnamedPlayer;
nohelperais=0;
}
]]
))
end

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



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

comment:7 by Bluestone, 6 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, 6 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, 6 years ago

Resolution: no change required
Status: newclosed

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

Note: See TracTickets for help on using tickets.