Page 1 of 1

Spring.Rehost("SomeStartScript.txt")

Posted: 15 Mar 2009, 04:17
by zwzsg
In order to make campaigns, I determined that I needed a command Spring.Rehost("SomeStartScript.txt"), accessible from unsynched gadget. The argument should be able to be both a path/file from inside the mod, or an external file. I would also need the file write commands necessary for my Lua to write the script, then. Maybe limited to data files and to some odd temp directory for security reason, I don't care as long as I can write my startscript file then feed it to rehost command.

Right now I can workaround using non-portable soon-to-be-plugged security holes. And if that stop working in next version and the rehost command I asks for is not implemented, I can still use an external launcher. But I feel it would be better to have it all inside the mod Lua, and for that I need that rehost command (and ability to write files.)

Re: Spring.Rehost("SomeStartScript.txt")

Posted: 15 Mar 2009, 04:47
by MidKnight
sorry for derailing this, but...

KP CAMPAIGN!!?!?!??!?! AWESOME! :P

Re: Spring.Rehost("SomeStartScript.txt")

Posted: 15 Mar 2009, 06:27
by zwzsg
Yes. Shortly after DNF.

Re: Spring.Rehost("SomeStartScript.txt")

Posted: 16 Mar 2009, 03:54
by Argh
1. Gadgets couldn't use io.write, last time I tested. If you've found a way around that, I'd like to hear about it, otherwise it's Widgets to do io.

2. Gadgets can send signals to Widgets.

3. I don't think that anybody's planning to make it impossible for io to be used to write new Lua, just executables.

4. I'm really not sure why you want to rehost, instead of just sending people to a menu where they can decide whether or not to continue (and yeah, that could be done in-game, with a reset of the map via Gadget, etc.). I mean, if you want to do "cut scenes"... simple still shots / text can be very easily implemented in Lua at game-end.

Re: Spring.Rehost("SomeStartScript.txt")

Posted: 16 Mar 2009, 04:15
by zwzsg
1) Hence being posted in "Feature Requests"

2) Ok. But widgets can be turned off much more easily than gadgets.

3) Hoping so, but you never know.

4) Do you know any way to change map without rehosting?



simple still shots / text
We are in the year 2009.

Re: Spring.Rehost("SomeStartScript.txt")

Posted: 16 Mar 2009, 13:10
by AF

Code: Select all

#include <iostream>
#include <fstream>
using namespace std;

int main(char** args, int argc){
    system("spring.exe menuscript.txt");
    ofstream myfile;
    myfile.open ("script.txt");
    if (myfile.is_open()){
        system("spring.exe script.txt");
    }
    return 0;
}
Now your only issue is getting your gadget to write script.txt, and could probs do with deleting the script.txt afterwards

Re: Spring.Rehost("SomeStartScript.txt")

Posted: 16 Mar 2009, 18:26
by zwzsg
AF: It's odd that you told Forb to post about my launcher yet seem to have forgotten about it now.

More clearly, I have alread written and released a C++ app that run Spring with a given startscript (and of course it's a shitload more complicated than what you wrote, you need to check that previous Spring.exe has ended, you'd need to parse the infolog or whatever to detect the previous mission was won, etc...). Problem with that are:
- Only work when the player is nice and agrees to always pass through my launcher. (And don't tell me about your stupid wrappers ideas).
- One more exe cluttering Spring folder.
- Not every campaign makers might want to learn how to make a PC program just to have each mission follows.
- I don't know how to write .exe for Linux. Halp me!
- I believe it would be much more clean to have that one Lua command than to rely on external .exe


Argh, AF: I'm not asking for shitty workarounds, I already have them. I'm asking for a Spring dev to implement that small Lua command to have things done right and clean.

Re: Spring.Rehost("SomeStartScript.txt")

Posted: 16 Mar 2009, 19:28
by Argh
It'd be great, to do it all from within Spring, I agree. So, +1 to your request.