I need a Spring.Rehost command!
Moderator: Moderators
I need a Spring.Rehost command!
I improved my integrated launcher. I moved the code that invent a random skirmish and write the corresponding startscript from the C++ of an out of Spring .dll, to a Lua widget inside the mod. However, there is one last blocking point: Spring is currently unable to relaunch itself, and I still have to use an external .dll just to run "Spring.exe myKPstartscript.txt". This is bad because:
- Not portable, only run on Windows
- The running of .dll by widget will soon be outlawed for security reason.
I would need a single Lua command, Spring.Rehost("somefile.txt"), and then I can have my Single Player Lobby all inside my mod, clean and portable.
It should be executable by both widgets and unsynced gadget.
The argument should be the filename of the startscript.txt. By the way don't remove me file:write please. It would be nice if it could also directly read a startscript from the mod archive, in addition to a file in Spring's root folder.
Such a command would also greatly help in making campaigns.
- Not portable, only run on Windows
- The running of .dll by widget will soon be outlawed for security reason.
I would need a single Lua command, Spring.Rehost("somefile.txt"), and then I can have my Single Player Lobby all inside my mod, clean and portable.
It should be executable by both widgets and unsynced gadget.
The argument should be the filename of the startscript.txt. By the way don't remove me file:write please. It would be nice if it could also directly read a startscript from the mod archive, in addition to a file in Spring's root folder.
Such a command would also greatly help in making campaigns.
Re: I need a Spring.Rehost command!
I'd suggest that instead of a filename it takes the entire startscript as a string, this way you don't have to bother about writing it to a temporary file at all.
(A version taking filename could very easily be implemented in Lua itself if the engine provides a version which takes entire startscript as string. With the added advantage that you can choose whether you load the script from mod, map, or raw filesystem.)
(A version taking filename could very easily be implemented in Lua itself if the engine provides a version which takes entire startscript as string. With the added advantage that you can choose whether you load the script from mod, map, or raw filesystem.)
Re: I need a Spring.Rehost command!
I had the notion that handling super long strings was bad, and constructing them by appending small bits after small bits even worse.
Otherwise yes.
Otherwise yes.
Re: I need a Spring.Rehost command!
Handling super long strings is only bad when they are longer then about 2^23 bytes (8M), IIRC (may be mistaken a few factors of 2).zwzsg wrote:I had the notion that handling super long strings was bad, and constructing them by appending small bits after small bits even worse.
Constructing them by appending small bits is O(n^2) algorithm yeah.
Better use:
Code: Select all
local s = {}
s[#s+1] = "first part"
s[#s+1] = "second part"
s[#s+1] = "third part"
-- etc.
s = table.concat(s)
(And yeah, I realize the s[#s+1] can be optimized even further, but I doubt it matters.)
Re: I need a Spring.Rehost command!
16M, because of the implicit 1.xxx
But that's only for splitting where you need to worry about precision.
But that's only for splitting where you need to worry about precision.
Re: I need a Spring.Rehost command!
So, will I have it, or is any development on my Lua Single Player battleroom doomed to the trashbin? (Since the .ddl exploit has been fixed it won't work without rehost command.)
Also, if you broke startscript syntax again, link me the new specs. Current test build says: Could not find 'gamedata/parse_tdf.lua' code. Ok, apparently, that bug is not related to starscript syntax change, but to "somewhere around" SpringData config key being empty. Somehow, SpringLobby manage to get Spring.exe running fine with that key empty, but drag and dropping a startscript over Spring.exe, requires it to be set to Spring folder. Startscript syntax still changed however since I got a gameover on start. Apparently there is now an [AIx] section for bots and, and god now what else. Hmm, I now got both my Kernel_Panic_3.2_Launcher.exe and my widget thing to write startscript accepted by test build spring.exe, so nevermind.
Also, if you broke startscript syntax again, link me the new specs. Current test build says: Could not find 'gamedata/parse_tdf.lua' code. Ok, apparently, that bug is not related to starscript syntax change, but to "somewhere around" SpringData config key being empty. Somehow, SpringLobby manage to get Spring.exe running fine with that key empty, but drag and dropping a startscript over Spring.exe, requires it to be set to Spring folder. Startscript syntax still changed however since I got a gameover on start. Apparently there is now an [AIx] section for bots and, and god now what else. Hmm, I now got both my Kernel_Panic_3.2_Launcher.exe and my widget thing to write startscript accepted by test build spring.exe, so nevermind.
Re: I need a Spring.Rehost command!
the start script is being read in as lua anyway? so couldn't there be an option to pass a table and not a string instead? That way all you need is a default lua script to generate a table then modify it at runtime in memory by changing the values in it then pass it to the engine.
Re: I need a Spring.Rehost command!
It isn't read in as Lua (yet).
Re: I need a Spring.Rehost command!
I already have done the whole generating and writing a startscript from a gadget, so it wouldn't take more time to use what I already have than to rewrite it to conform to a new format.AF wrote:That way all you need
Would appreciate if startscript syntax/format/standard stopped changing btw.
Re: I need a Spring.Rehost command!
You wouldn't need to handle syntax etc if it was a lua table, and you wouldn't run into the issues regarding read only file systems too.
Re: I need a Spring.Rehost command!
Yes, because Lua has no syntax, and because Lua code write itself, of course.AF wrote:You wouldn't need to handle syntax etc if it was a lua table
I am fine with Tobi proposal of long string.AF wrote:you wouldn't run into the issues regarding read only file systems too.
Re: I need a Spring.Rehost command!

I'd really like such a Spring.Rehost(str) command.
Think of all the amazing things we could do with it:
- A single player lobby as a widget, integrated into Spring (my widget is all ready, it just need that command).
- Very pretty skirmish menu, since we can use all the OpenGL Lua command: I could make semi-transparent animated 3D menu, I could use unit model as bullet point with gl.UnitShape, I could run an AI battle or whatever game scene in the background, etc...
- Easy to write skirmish menu, since we have so many Lua coders around. I'm sure I won't be the only one to write one.
- Dumb newb that don't know they are not supposed to run Spring.exe would not get the bad impression left by the hardcoded startscripts.
- Missions that launch other missions, forming a campaign.
- Dynamic campaign, since we have access to the full game state when we decide relaunch it, we can branch to one mission or another, or even write a startscript customised to how the previous game ended (like count team alive, count resources, count unit alive, and write a startscript that give them back).
- No external application adding mess in the Spring folder: The SP menu of each mod would be contained within the mod archive: It's clean, and make it impossible to break by missing a file.
- Fully cross-platform with zero porting work, since it would be entirely done within Spring Lua.
So please, give me that Spring.Rehost(str)
Whether "str" is the startscript.txt filename or the content of the startscript as one huge string, I don't care, do as you want.
Re: I need a Spring.Rehost command!
Check the commits, looks like you got your wish!
Sooo... anybody want to pool resources and build a solid launcher / configuration toolset and UI?
Sooo... anybody want to pool resources and build a solid launcher / configuration toolset and UI?
-
- Spring Developer
- Posts: 1254
- Joined: 24 Jun 2007, 08:34
Re: I need a Spring.Rehost command!
I like the picture.
Re: I need a Spring.Rehost command!
I'd really like to test it, as I am currently writing widgets making use of it, but Spring stopped working for me between 0.79.0-524-g2e8ff49 and 0.79.0-541-g892ce49. And I'm being told it won't get fixed unless I learn to compile Spring and to debug it myself. 
How hard would it be to make me a builld of Spring with just that Lua call ported back on an older Spring version?
Edit: dizekat helped me narrowed it down to one single commit:
I tested spring_exe_0.79.0-532-gb9bc44f.zip and it works
I tested spring_exe_0.79.0-533-g687f388.zip and it fails
Edit: Ok, finally Test Build works on my ATI, and I could that new command it.
Spring.Restart("-w",VFS.LoadFile("Kernel_Panic_script.txt")) works! Woot!
Spring.Restart("",VFS.LoadFile("Kernel_Panic_script.txt")) and Spring.Restart("Kernel_Panic_script.txt","") make it reload to the hard-coded Spring Menu.
What does -w stand for? Where do I find list of Spring.exe option?

How hard would it be to make me a builld of Spring with just that Lua call ported back on an older Spring version?
Edit: dizekat helped me narrowed it down to one single commit:
I tested spring_exe_0.79.0-532-gb9bc44f.zip and it works
I tested spring_exe_0.79.0-533-g687f388.zip and it fails
Edit: Ok, finally Test Build works on my ATI, and I could that new command it.
Spring.Restart("-w",VFS.LoadFile("Kernel_Panic_script.txt")) works! Woot!
Spring.Restart("",VFS.LoadFile("Kernel_Panic_script.txt")) and Spring.Restart("Kernel_Panic_script.txt","") make it reload to the hard-coded Spring Menu.
What does -w stand for? Where do I find list of Spring.exe option?
Re: I need a Spring.Rehost command!
Code: Select all
spring --help
Code: Select all
-w [ --window ] Run in windowed mode
Re: I need a Spring.Rehost command!
on windows, you'll need to do to see anything.
Code: Select all
spring --help >help.txt
Re: I need a Spring.Rehost command!
I use:hoijui wrote:Code: Select all
-w [ --window ] Run in windowed mode
Spring.Restart("-w",VFS.LoadFile(ModSpecific.ScriptFileName))
And it works and Spring doesn't change to windowed mode.
When I use:
Spring.Restart("",VFS.LoadFile(ModSpecific.ScriptFileName))
Spring instead of using the specified scipt, restart to hard coded Spring menu.
But then I used:
Spring.Restart(" ",VFS.LoadFile(ModSpecific.ScriptFileName))
And it worked too.
So I suppose the problem is that Spring.Restart doesn't like its first argument to be an empty string.
-
- Spring Developer
- Posts: 1254
- Joined: 24 Jun 2007, 08:34
Re: I need a Spring.Rehost command!
Code: Select all
const string arguments = luaL_checkstring(L, 1);
const string script = luaL_checkstring(L, 2);
Re: I need a Spring.Rehost command!
Yes, lua_f(L, i) always refers to the i'th Lua function argument on the stack.