Search the Community
Showing results for tags 'saving'.
Found 4 results
Hi, i 've got a problem with asteroid contracts which come with the condition "Have a previously undisturbed Class X asteroid in tow" resetting whenever i save&load. Specifically i'm dealing with a contract to put a Class E into orbit of Minmus which is quite time-consuming with ISRU and low dV changes, but i can not save my progress because whenever i have my vessel "docked"(3 Klaws i rammed into the rock) and saved, the asteroid in question is not registered as previously undisturbed/part of the contract anymore. Meaning i can't solve the contract. The same problem arises with another contract which asks for station building around Duna on a previously undisturbed asteroid (i think, the condition also resets when changing vessels on map mode), making rendezvous with station parts after orbital insertion impossible. Is there a trick to circumvent this? Like savefile hacking to make the asteroid a viable target again or sth?
Hello there! I've been working on my mod, PersistentRotation, for quite a long time. If you never heard of it make sure to check it out, to know what I am talking about. The mod is currently saving it's data into a custom made cfg file. Every time the game quicksaves or switches scenes, a new file is generated. While I have added code to clean up deprecated versions of the file, I still have the feeling that it isn't the optimal solution to store the data. A while ago, I have heard about saving mod data to the game's sfs files. This would of course be a a lot more effective way of storing data. Now, the problem is, my mod saves data per vessel and has no custom parts at all. Could someone explain me how to do this or send me the corrseponding piece of code? Thanks in advance.
Hi! This is my first post to this forum, so I hope everything is alright. I've been searching here and on Google for a week and hit an enormous amount of dead ends. As the title says, I've hit a wall with the KSPScenario system, trying to save/load data from my mod. I have my save/load methods properly overridden in a ScenarioModule tagged with the KSPScenario attribute. I have a static Dictionary in another class with the data I want to save. Beyond there is where the problems begin. My custom PartModule has to do some math upon startup to deduct resources. Initially I figured, great, I'll do it in OnStart. However, the Scenario Module always runs OnLoad after the PartModule's OnStart, loading data into memory from BEFORE the update. Here is the current flow: -- Flight Scene is loaded -- PartModule.OnStart(..) Check tracking info, which is already in memory, in State 1 Update tracking to State 2 ScenarioModule.OnLoad(..) Loads tracking info still in State 1 - correct data is overridden! ScenarioModule.OnSave(..) PartModule.FixedUpdate(..) Sometimes starts as early as before ScenarioModule.OnLoad(..) PartModule.OnStart takes the initial values (State 1), updates them (State 2), and then returns. When ScenarioModule.OnLoad is called, it overwrites the data, putting it back in State 1. Ideally OnLoad would only trigger when loading from a persistence file, but I haven't found a way to control for that. I have tried an enormous amount of workarounds, including: Manually invoke ScenarioModule.OnSave(..) at the end of OnStart with a modified, correct ConfigNode. OnLoad still loaded the stale data. Move OnStart logic to OnInitialize. This worked when loading a vessel already in flight, although OnInitialize started an indeterminate time after FixedUpdate began iterating. The problem arose when creating a new vessel (i.e. vessel rollout). There, OnInitialize was triggered so EARLY that the PartModule's reference to vessel was null. Try manually writing/loading to persistent.sfs at the end of OnStart, similar to item #1. Made me uneasy, but no matter - it didn't work anyway. Try waiting for FlightGlobals.ready before doing the initialization logic. This flag sometimes triggered before OnLoad, and sometimes after. Block the loader and/or the game from proceeding until the other had reached an acceptable point. These worked in a vacuum, but are impossible to get working when multiple vessels are active, for the simple reason that I cannot tell whether OnLoad is simply loading from a scene change, or from a user-instigated persistence file load. Manually modify the ScenarioModule's ConfigNode (via snapshot.GetData()). Tweak the KSPScenario attributes. I've tried just SpaceCenter, just PSystem (OnLoad/Save never fired), and the full collection of in-game scenes (SC, Tracking, Flight). The problem is that if I remove some of these scenes, then it will not load, but it also will not save. This was easily tested by trying to quicksave, then checking the log file. Throw an exception in OnLoad to manually check the stack track for "GamePersistence.LoadGame." This would work for OnSave (which I don't need to touch), but for OnLoad the source is ScenarioRunner.AddModule every time. ...and more How can I save data to the persistence file (using a ScenarioModule, I assume) without it being overwritten? I've tried so many things at this point, I'm starting to go crazy. It doesn't seem like anything involving the load sequence is deterministic. I also suspect (from the aforementioned stack traces) that the game is actually adding a new copy of the scenario to every scene via ScenarioRunner.AddModule. Even if I just specify one scene (e.g. GameScenes.SPACECENTER), it does this every time I load the SpaceCenter. Every post I've found says ScenarioModules are the way to go if saving data to the persistence file, but it seems like such a convoluted way to operate. On the other hand, I used to be load/saving via GameEvents.OnGameStateSaved.Add(..), and I suspect I'd have the same problems there. ...Bottom line is, I'm just looking to save some data. Any feedback on how I can do that? Thanks!