KSP-KOS / KOS

Fully programmable autopilot mod for KSP. Originally By Nivekk
Other
687 stars 229 forks source link

Allow selecting any flying vessel from Telnet #1596

Open hvacengi opened 8 years ago

hvacengi commented 8 years ago

Creating a new issue to encompass the conversation with @jonored in PR #1560.

The basic goal is to be able to add a sub menu to the telnet client to select any flying vessel and make it the active vessel.

I'd also like this to include the ability to launch a new craft, replicating some of the functionality from #1560.

hvacengi commented 8 years ago

Ultimately, this seems redundant if a mainframe happens, but it gets you most of the way to the mainframe's basic usefulness if you've got a usable module /somewhere/ to swap to.

I actually still would like the functionality to be independent of the mainframe system for the sake of external automation.

jonored commented 8 years ago

Another thing that I'm adding to the telnet menu: revert to launch. Crashing should make restarting the mission as easy over telnet as it is in the GUI.

hvacengi commented 8 years ago

If you take my implementation from inside kuniverse and put it into a utility class, we can maintain a single code base for the same function.

Since this exists in the script land already, I presume you are looking to do it after the processor has been destroyed, thereby locking you out of the scripting interface. In that case you should watch out for a way to dismiss the flight log dialog box that pops up after a little bit.

jonored commented 8 years ago

This entire enhancement boils down to "access particularly useful functionality in currently in kuniverse from outside a script", so doing a little bit of refactoring there so there isn't duplication certainly makes sense.

jonored commented 8 years ago

Okay, this is progressing reasonably at this point. It took a bit more cleanup than I was planning on. That said, another bit that should be in the list occurred to me: loading a saved game as from the main menu (in particular, this makes iterating on the mod while not at the GUI quite a bit easier). I have it working for quicksaves to get that advantage to my development process, but I'm having trouble finding how to open to just the KSC scene (which would be more appropriate to include in the final extended menu); if anyone happens to have a pointer on that front it would be helpful.

hvacengi commented 8 years ago

I'd look at DarkMultiplayer. The mod first contacts the server to construct the KSP save file and then launches it (I think). Even if I have that slightly wrong, at the very least it it loads a save file on command. Maybe @godarklight can point you to the section of code.

I am glad you're thinking about this already. I was hoping that the system would be flexible enough to allow expanding it to loading saves. The other thing I'd like to expand it to is a tracking station like interface.

Neither of these two features need to be implemented before you submit the pull request though. If you post what you have, we can work on reviewing the existing code while you work on expanding features.

hvacengi commented 8 years ago

Looks like this is the applicable code: https://github.com/godarklight/DarkMultiPlayer/blob/master/Client/Main.cs#L499-L532

Obviously some of that is not applicable because he doesn't need to actually create the save file from scratch, it's just a matter of constructing the C# object and telling it to save itself. But it's a place to start.

I forgot to ask, you mentioned getting quicksaves to work, did you see that I have a PR pending with that functionality enabled for scripts?

jonored commented 8 years ago

I'm not going to keep it in for the first pull request, but given that most of the time I have to work on this I'm on the other side of a cellphone link from the machine that can actually run KSP and VNC is irritating to fire up just to click through to the situation I need to test something, it was relevant in an immediate sort of sense. I pulled the code from the quicksave patch and hooked it up to a menu option with a hardcoded save.

Where I'm going with the interface is phone-menu-like - you land on the current menu (on the theory that it's the most used) - but you can select * or 0 to go up a level, to a menu that has the sub-menus. I'm not looking at doing free input at this point, just selecting from lists in a little menu tree.

I'll post it once I've actually got the second real menu implemented (so it'll be select CPU and switch vessel).

jonored commented 8 years ago

Loading a game of all things is turning out to be difficult to get working properly; I get what looks like the unfocused version of the KSC scene, with the camera in a weird spot, rather than a correctly loaded game.

Currently, I'm doing:

HighLogic.SaveFolder = availableSaves[pickNumber-1];
ConfigNode node = GamePersistence.LoadSFSFile("persistent", HighLogic.SaveFolder);
HighLogic.CurrentGame = GamePersistence.LoadGameCfg (node, HighLogic.SaveFolder, false, false);
GamePersistence.UpdateScenarioModules(HighLogic.CurrentGame);
GameEvents.onGameStatePostLoad.Fire(node);
GamePersistence.SaveGame(HighLogic.CurrentGame, "persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
HighLogic.CurrentGame.Start();

which I pulled from the normal game load menu, with the omission of the update pipeline. Oddly, loading a quicksave instead of the main save appears to work.

I don't see anything in the logs that is immediately apparent as different between this and a normal load, either.