![](https://forum.kerbalspaceprogram.com/uploads/set_resources_17/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
![](https://forum.kerbalspaceprogram.com/uploads/set_resources_17/84c1e40ea0e759e3f1505eb1788ddf3c_default_photo.png)
DMagic
Members-
Posts
4,180 -
Joined
-
Last visited
Content Type
Profiles
Forums
Developer Articles
KSP2 Release Notes
Everything posted by DMagic
-
That's where they put burned out Kerbalnauts to pasture.
-
[WIP] DMagic Orbital Science: New Science Parts - V0.8.2 (7/17/2014)
DMagic replied to DMagic's topic in KSP1 Mod Development
Do you mean during EVA? A bug snuck in between the last two updates that broke EVA data collection for the magnetometer. It's just a misspelling in the part.cfg file (where it says "dataIsCollectible", it should say "dataIsCollectable"). I fixed that for the next update as well as all of the other .cfg file bugs that snuck in. That's actually a pretty good idea, though something other than a right-click button would probably be best. Trueborn's Custom Biomes plugin comes with a little map that tells you which biome you're currently in (biome edges are fuzzy though, and will return the wrong area). The update is almost ready. I only need to finish writing the new science reports and do a little more testing. I also need to give the existing parts a through check to make sure nothing else breaks like last time. -
[WIP] DMagic Orbital Science: New Science Parts - V0.8.2 (7/17/2014)
DMagic replied to DMagic's topic in KSP1 Mod Development
The next update is nearing completion. It's mostly ready, there are just some nagging issues that keep popping up with the transmitter and science lab interaction. Any functions that go through the transmitter or the lab, and not the part itself are a little tricky to deal with. On the plus side, though, I've found out something very interesting about how the transmitter works. When you right click on the transmitter to send your data (instead of going through the results page) it calls the DumpData() method from the part's module. Which is great because it means I can fully control what happens when you send data that way; I can prevent exploits and run whatever code I need through both forms of transmission. Now if I could just find a way to access the science lab's cleanExperiment function I would be set, but I might have to settle for manually resetting experiments. I've also been working on a generic replacement plugin for my first four parts. Instead of relying on four fairly similar plugins I want to create one plugin that only needs to be configured through the part.cfg file and can handle several different animation situations and other limitations. I have it mostly working, it's just those science lab and transmitter problems again. When I get it to a more completed state I plan on releasing it for anyone else to use. There are quite a few animated science mod parts that don't work well with the default ModuleScienceExperiment and ModuleAnimateGeneric. Using those modules can cause parts to stay in the deployed state longer than you want them to, or to play the reverse animation when you don't want them to. There are a few other issues with those modules that I can hopefully work around. All of the other work on my new part is completed, and I've retextured the magnetometer and laser to better fit in with my newer parts. I've also fixed the bugs that somehow snuck into some of the .cfg files between 0.5 and 0.6, I don't know how they got in there, but they shouldn't be a problem anymore. The RPWS and telescope will have to wait for another update before they get any love, both need new models and textures. -
Download from CurseMediaFire Link Updated to better handle quick-load plugins. This simple plugin generates a variable number of backup persistent files in your savegame folder. The number of backups can be altered with the included Settings.cfg file. Version 0.3: Should now be working with any plugin that bypasses the main menu and loads directly into the space center or an active vessel (really this time). Version 0.3.1: Compiled against .net 3.5, ModStatistics should no spam debug log errors To restore a backup just rename the original persistent file, then rename the desired backup from "persistent Backup 3" to "persistent" (without "" and using the # from the desired backup) and it should now load with the working file. This is intended to serve as a protection against persistent file corruption or from having your vessels wiped out by missing parts. It is not intended to be used for save scumming (reloading a save file over and over to get something perfect). Backup save files are only generated when a file is first loaded from the mainmenu. Source is available in the download and on GitHub. License under the 2-clause BSD: BSD License
-
Yeah, what GavinZac said. I'm not really concerned about disk space either, it's more that you could end up with hundreds of files doing nothing in your save folder, and there's really no need for that. I mostly made it by working backwards from an autoload plugin that skips right to an active vessel. You can see how simple the basic version is, it's about 10 lines. All of the complexity comes from checking existing backups to create a variable amount, but even still, it's pretty simple. I think this update is about final. It actually does what I intend it to and locates the oldest file, instead of just pretending to like the last version. I also added a bunch of checks to make sure that no one can screw up the Settings.cfg file enough to break it. I put it up on Spaceport if anyone's interested: http://kerbalspaceprogram.com/dmagic_autosave/ The only issue is that it doesn't seem to work when used in conjunction with autoload plugins that bypass the main menu. It just saves a "just started" persistent file with almost nothing in it. Some of these plugins might work (there are a lot of different versions floating around), but the one I'm using doesn't. using System; using System.Collections.Generic; using UnityEngine; using System.IO; namespace AutoSave { [KSPAddon(KSPAddon.Startup.MainMenu, false)] public class AutoSave : MonoBehaviour { private int max = 3; protected ConfigNode node = null; private string path = null; public void Start() { GameEvents.onGameSceneLoadRequested.Add(saveBackup); } public void saveBackup(GameScenes scene) { if (HighLogic.LoadedScene == GameScenes.MAINMENU) { DateTime oldestFile = new DateTime(2050,1,1); string replaceBackup = null; string activeDirectory = Path.Combine(Path.Combine(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName, "saves"), HighLogic.fetch.GameSaveFolder); path = Path.Combine(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName, "GameData/AutoSave/Settings.cfg").Replace("\\","/"); if (File.Exists(path)) //Load Settings.cfg to check for change in max number of saves { max = getMaxSave("MaxSaves"); print("Changing max saves value to " + max.ToString()); } for (int i = 0; i < max; i++) { string filepath = Path.Combine(activeDirectory, "persistent Backup " + i.ToString() + ".sfs"); if (!File.Exists(filepath)) { replaceBackup = "persistent Backup " + i.ToString(); break; } else //If all backups have been written, check for the oldest file and rewrite that one { DateTime modified = File.GetLastWriteTime(filepath); if (modified < oldestFile) { replaceBackup = "persistent Backup " + i.ToString(); oldestFile = modified; } } } var save = GamePersistence.SaveGame(replaceBackup, HighLogic.fetch.GameSaveFolder, 0); GameEvents.onGameSceneLoadRequested.Remove(saveBackup); } } public int getMaxSave(string entry) //Make sure that no amount of screwing up the Settings file will break the plugin. { int number = 3; node = ConfigNode.Load(path); if (node != null) { string value = node.GetValue(entry); if (value == null) return number; else if (Int32.TryParse(value, out number)) return number; else return 3; } else return number; } } }
-
[1.8.x] DMagic Orbital Science: New Science Parts [v1.4.3] [11/2/2019]
DMagic replied to DMagic's topic in KSP1 Mod Releases
It's possible, but that shouldn't be an issue with anything beyond version 0.5 of my mod. I don't use ModuleScienceExperiment on any of the parts (though some of them do use a plugin that inherits from that). It's worth considering though. -
Stick a fork in it, I think it's done. This sets a default value of three backups and it can be changed using the included Settings.cfg file. I should probably test it a little more to make sure it works and doesn't break if you screw up the .cfg file, but otherwise I think it's good. I'll upload the plugin later. using System; using System.Collections.Generic; using UnityEngine; using System.IO; namespace AutoSave { [KSPAddon(KSPAddon.Startup.MainMenu, false)] public class AutoSave : MonoBehaviour { public int max = 3; protected ConfigNode node = null; string path = null; public void Start() { GameEvents.onGameSceneLoadRequested.Add(saveBackup); } public void saveBackup(GameScenes scene) { scene = HighLogic.LoadedScene; if (scene == GameScenes.MAINMENU) { DateTime oldestFile = new DateTime(2050,1,1); string replaceBackup = null; string activeDirectory = Path.Combine(Path.Combine(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName, "saves"), HighLogic.fetch.GameSaveFolder); path = Path.Combine(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName, "GameData/AutoSave/Settings.cfg").Replace("\\","/"); FileInfo settings = new FileInfo(path); if (settings.Exists) { max = getMaxSave("MaxSaves"); print("Changing max saves value to " + max.ToString()); } for (int i = 0; i < max; i++) { FileInfo backup = new FileInfo(Path.Combine(activeDirectory, "Persistent Backup " + i.ToString() + ".sfs")); if (!backup.Exists) { replaceBackup = "Persistent Backup " + i.ToString(); break; } else { DateTime modified = backup.LastAccessTime; if (modified < oldestFile) { replaceBackup = "Persistent Backup " + i.ToString(); oldestFile = modified; } } } var save = GamePersistence.SaveGame(replaceBackup, HighLogic.fetch.GameSaveFolder, 0); GameEvents.onGameSceneLoadRequested.Remove(saveBackup); } } public int getMaxSave(string max) { node = ConfigNode.Load(path); if (node != null) { string value = node.GetValue(max); return Convert.ToInt32(value); } else return 3; } } }
-
Trigger a part's action from code?
DMagic replied to Diazo's topic in KSP1 C# Plugin Development Help and Support
Pretty much everything that I make with a KSPEvent also gets a KSPAction, the Action usually just points to the Event. If there's ever a situation where both aren't used it's usually the Event that I take out, I can imagine people doing the opposite though. I suppose one difference is that Events include all of the GUIActiveUnfocused stuff, like EVA events, or select target events, but I'm not sure there's ever a real reason to assign those to action groups. -
Ever get the feeling that your parents dropped you on your head when you were little? like, repeatedly? I knew that checking existing backups would require knowing the current savefile directory. Getting the main KSP directory is easy enough, then just append 'saves' to the end. But it took me forever to figure out how to get the name of the directory for the current savefile, only to realize that it was staring right at me, in the code I had already written and posted, just above this post; HighLogic.fetch.GameSaveFolder. So anyway, this code makes two backups. It checks for existing backups, then takes the 'recent' backup and copies it over the old backup before creating a new 'recent' file. Unfortunately, it's not scalable. I need a different way to make three, or preferably one that makes three by default but allows an easy way to specify however many you want. I think I just need to make a loop that checks for the LastModifiedTime and returns the oldest file. I'll see what I can come up with. using System; using System.Collections.Generic; using System.Linq; using UnityEngine; using System.IO; namespace AutoSave { [KSPAddon(KSPAddon.Startup.MainMenu, false)] public class AutoSave : MonoBehaviour { public void Start() { GameEvents.onGameSceneLoadRequested.Add(saveBackup); } public void saveBackup(GameScenes scene) { scene = HighLogic.LoadedScene; if (scene == GameScenes.MAINMENU) { //This doesn't seem to like combining three strings into one path for some reason, so I combine two strings twice, I'm guessing the "saves" string needs some kind of / \. string activeDirectory = Path.Combine(Path.Combine(new System.IO.DirectoryInfo(KSPUtil.ApplicationRootPath).FullName, "saves"), HighLogic.fetch.GameSaveFolder); System.IO.FileInfo oldBackup = new System.IO.FileInfo(Path.Combine(activeDirectory, "Persistent Backup.sfs")); if (oldBackup.Exists) { System.IO.FileInfo newBackup = new System.IO.FileInfo(Path.Combine(activeDirectory, "Persistent Backup Most Recent.sfs")); if (newBackup.Exists) newBackup.Replace(Path.Combine(activeDirectory, "Persistent Backup.sfs"), Path.Combine(activeDirectory, "Persistent Backup Most Recent.sfs")); var save = GamePersistence.SaveGame("Persistent Backup Most Recent", HighLogic.fetch.GameSaveFolder, 0); GameEvents.onGameSceneLoadRequested.Remove(saveBackup); } else { var save = GamePersistence.SaveGame("Persistent Backup", HighLogic.fetch.GameSaveFolder, 0); GameEvents.onGameSceneLoadRequested.Remove(saveBackup); } } } } }
-
I threw out the bool, so now the plugin runs every time you go back to the main menu. This way you can load several save games and it will make a backup each time, but only when you back out to the main menu. This seems like the best way to do it, if your save file was working the last time you quit, then the backup should also work (as long as you fix whatever broke your main persistent file in the first place). I changed the code in the preview above, though I haven't actually uploaded a new version. I think what's shown above is about as simple as it's going to get. This is probably a good idea, I'll try to find a way to do this. This might also be a good idea, but it seems like it might run afoul of the rule about not altering or creating files outside of the KSP directory.
-
This should be interesting. I'll have to try it out soon. That's a good idea with the heading device, it's a shame there's no easier way to get that information. One suggestion based on your images, those bearing and heading numbers can probably be rounded off (and I assume since your write-up has the correct bearing/heading terminology that you'll change that too). I assume they're doubles so just replace them with: Math.Round(yourdouble, 2); with the 2 being how many decimal places to include. And does a Kerbal day mean 10 hours (or whatever a full day on Kerbin is)? It's always been a bit confusing because the time references all seem to be Earth days and years, while Kerbin days and years are completely different.
-
Yeah, I usually catch it too, but I really hate it when I'm not thinking click through to some other scene. This might also be useful for development. I have run into issues a number of times where some error while loading a plugin has nuked all of my parts (not just the mod parts, everything), so not only do you lose the crafts, but you have to repurchase everything in the R&D center. A backup would be nice then. If you're using some kind of quickload plugin to skip the spacecenter scene this plugin might not work, but it can probably be easily modified to fix that. The key part is creating the save file while still in the MainMenu scene, that way nothing can get corrupted by errors after loading. Edit: Just realized the time stamp was a bad idea. You'd get an ever-growing list of backups, better to create one and overwrite it. I updated the link and source.
-
[1.8.x] DMagic Orbital Science: New Science Parts [v1.4.3] [11/2/2019]
DMagic replied to DMagic's topic in KSP1 Mod Releases
I just tested it out with FAR, Deadly Reentry, SCANsat, my BTDT scanner, and the 0.6 version of my mod and everything was working ok. Were the parts ever working properly? or have they been bugged since you installed them? You could always try re-downloading and re-installing them, you never know. I'll let you know if I find anything else. -
That's right, I'm replying to my own post... And hey, this might do just what I was saying: http://forum.kerbalspaceprogram.com/threads/71624-Plugin-Auto-Create-Persistence-File-Backup-Prevent-File-Loss-From-Missing-Parts I haven't tested it much, but it's supposed to create a backup whenever you first load a save file. It's a bit of a WIP though, so I wouldn't rely on it too much.
-
CurseForge Link Mediafire link:http://www./download/98wkt28ke25gsxn/DMagic_AutoSave_V3.1.zip Version 3.1 is compiled against .net 3.5 and won't cause ModStatistics to throw debug log errors ----- So after looking at one of the threads over in the suggestion forum I realized that a simple plugin should be able to create a backup persistence file to prevent the old "Missing Part-now a dozen vessels are deleted" thing from happening. Yes, the best way to prevent this is to make your own backups and immediately quit after getting the "Missing Parts" message, but that doesn't always happen. The plugin generates a new backup file every time you restart KSP, it only does so once per game, but resets when you back out to the main menu. The included settings.cfg file can be used to specify the number of backups to generate before the plugin begins overwriting old files. And here's the code if anyone wants to check for some boneheaded mistake, or any potentially catastrophic errors waiting to happen: using System; using System.Collections.Generic; using UnityEngine; using System.IO; namespace AutoSave { [KSPAddonImproved(KSPAddonImproved.Startup.SpaceCenter | KSPAddonImproved.Startup.Flight | KSPAddonImproved.Startup.EditorAny | KSPAddonImproved.Startup.TrackingStation | KSPAddonImproved.Startup.MainMenu, false)] public class AutoSave : MonoBehaviour { private int max = 3; private ConfigNode node = null; private string path = null; private static bool Saved; public void Start() { if (HighLogic.LoadedScene == GameScenes.MAINMENU) Saved = false; else if (Saved == false) saveBackup(); } public void saveBackup() { DateTime oldestFile = new DateTime(2050, 1, 1); string replaceBackup = null; string activeDirectory = Path.Combine(Path.Combine(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName, "saves"), HighLogic.fetch.GameSaveFolder); path = Path.Combine(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName, "GameData/AutoSave/Settings.cfg").Replace("\\", "/"); if (File.Exists(path)) //Load Settings.cfg to check for change in max number of saves { max = getMaxSave("MaxSaves"); print("Changing max saves value to " + max.ToString()); } for (int i = 0; i < max; i++) { string filepath = Path.Combine(activeDirectory, "persistent Backup " + i.ToString() + ".sfs"); if (!File.Exists(filepath)) { replaceBackup = "persistent Backup " + i.ToString() + ".sfs"; break; } else //If all backups have been written, check for the oldest file and rewrite that one { DateTime modified = File.GetLastWriteTime(filepath); if (modified < oldestFile) { replaceBackup = "persistent Backup " + i.ToString() + ".sfs"; oldestFile = modified; } } } File.Copy(Path.Combine(activeDirectory, "persistent.sfs"), Path.Combine(activeDirectory, replaceBackup), true); print("Backup saved as " + replaceBackup); Saved = true; } public int getMaxSave(string entry) //Make sure that no amount of screwing up the Settings file will break the plugin { int number = 3; node = ConfigNode.Load(path); if (node != null) { string value = node.GetValue(entry); if (value == null) return number; else if (Int32.TryParse(value, out number)) return number; else return 3; } else return number; } } } If anyone spots any issues, has any suggestions, or thinks this is a dumb idea, let me know. License for plugin software: BSD License
-
[1.8.x] DMagic Orbital Science: New Science Parts [v1.4.3] [11/2/2019]
DMagic replied to DMagic's topic in KSP1 Mod Releases
I will try out FAR and Deadly Reentry later tonight to see if they are causing issues. Do they alter my parts at all, or do those values come from something the plugin is doing? I know that they use modulemanager to alter some parts, but I thought that was limited to stock parts. I've seen the "look rotation" spam before, too, it's really annoying but it always stopped after a few seconds for me. Does it happen only in the spacecenter view (that's where I always saw it)? If it does ever stop, try reloading the parts from the ALT F12 menu and check for that "module missing" line. My guess is that's the issue, but I don't know why it would happen. That BTDT shouldn't cause any problems, but I haven't actually tested that since I first released it. All it does is control the animations. There's some dim chance that some of the event or action names is causing a conflict somewhere. I'll test it later tonight too. -
[1.8.x] DMagic Orbital Science: New Science Parts [v1.4.3] [11/2/2019]
DMagic replied to DMagic's topic in KSP1 Mod Releases
That's odd. None of the parts work? And you can't access the action group settings either? It sounds like the plugin modules are not being loaded. Do you get any error messages in the debug menu (Alt + F2)? There could be red errors showing up when the vessel is first loaded. There could also be an orange message while the game is loading saying something like "DMMagBoomModule Not Found", or something to that effect meaning that the part module wasn't loaded. Is the plugins folder in the right location (it shouldn't matter where it is, as long as it's somewhere in the GameData folder), and has the part.cfg file been edited in any way? -
[PLUGIN+PARTS][0.23] SCANsat terrain mapping
DMagic replied to damny's topic in KSP1 Mod Development
I think the fov limits itself to 20. You can try, and it might work, but at the least it will make it go much faster. -
[WIP] DMagic Orbital Science: New Science Parts - V0.8.2 (7/17/2014)
DMagic replied to DMagic's topic in KSP1 Mod Development
As for any real integration I can't really do that, it's all controlled by the interstellar plugin. What you can do, though, is copy the MODULE {name = DTMagnetometer } code from the interstellar magnetometer's .cfg file and put it in mine, then where it says "animname = ", replace whatever is there with "animname = magBoom". You can either delete my own module or try to use both, I'm not sure what will happen. But this should make my magnetometer function like the interstellar version (with all of the oddities in the animation, unless that's been fixed). You might also want to change the "name = " line at the top of the .cfg file so that you don't have any conflict with existing parts. Thanks. I haven't really started working on, or even thinking much, about the RPWS. I probably won't get to it for a while, and the next update (after the one I will release in a week or so) might not come until we get to 0.24. I think I'm done with any compatibility breaking updates, at the worst you might need to go back to the R&D center and repurchase a part from an already researched tech node. I'm not entirely sure what causes that to happen, so it's hard to control for. But the part names will all remain unchanged and the size of any new models will be about the same, a bit smaller maybe, but definitely not bigger. -
Community Mod Repository and The Majiir Challenge
DMagic replied to Majiir's topic in KSP1 Mods Discussions
I have never really cared for nexus, I'm not entirely sure why, but I think it's the sum of many minor issues. For one, I don't like the way images are handled. In my opinion the ideal image format for showcasing mods is an embedded imgur album. It allows for easy captions, it doesn't take up space, and it can be integrated with the text of the description without breaking things up too much. Not every mod relies on images, but a lot do, and nexus' system of pushing them onto a different tab, with no clear context doesn't seem very good to me. The general consensus here seems to be that we don't need another comment/question area, and nexus has two. Most importantly though, nexus lacks what I've already stated is the most important function to me, a big, obvious, idiot proof, Download - Here button. One that immediately downloads the file in question. -
[WIP Plugin] BDAnimationModules - v0.6.1
DMagic replied to BahamutoD's topic in KSP1 Mod Development
I think you can make it do a lot using only the .cfg file, it's just a matter of how many options you want to expose there and how complicated you want the plugin to be based on all of those .cfg fields. -
Single mesh. More than one material.
DMagic replied to Payload's topic in KSP1 Modelling and Texturing Discussion
The stock parts do it, but as far as I know it's only the ones with custom modules. I don't think anything using the ModuleAnimateGeneric can do it. So I don't think there's anything in the .cfg file for say, the landing legs, that specifies VAB editor options. -
Single mesh. More than one material.
DMagic replied to Payload's topic in KSP1 Modelling and Texturing Discussion
Are you just looking for a way to have textures on both sides of the mesh? You can just select everything that you want two-sided, duplicate it, and switch the normals on one set. I don't know about putting multiple materials on that same mesh, but you'll at least have textures on both sides. As for the VAB thing, you need a plugin with an [KSPEvent(guiactiveeditor = true, .....)]. That's what gives you the ability to right click on something in the VAB. I'm not sure about making it permanent (like launching with landing legs extended). I think maybe you need to set some persistent KSP field that's triggered by the VAB command, then check that when you launch. -
Community Mod Repository and The Majiir Challenge
DMagic replied to Majiir's topic in KSP1 Mods Discussions
As far as these concerns go, I think Spaceport has the right idea. Every mod should be packaged in one file, .zip only, no rar, tar, or anything else. I think it's the simplest solution, and the one least like to run into problems with people not knowing how/being able to extract the files (maybe there are issues of download integrity? Is there no way to verify that a zip package is not corrupted? Even if so, I think the simplicity outweighs this problem). I can see some justification for multiple downloads if there are some kind of alternate versions of the mod, but that is probably better handled by including all of the necessary files in one package. Onsite download is also a major feature in my opinion. The only reason I can think of to add alternate download links is if it is possible to access the site, but not be able to download from it. Otherwise alternate download links can live on the forums. And if the site is going to have some kind of log-in, then that should be required for uploading, if only to better categorize everything (ie: no mods listed by "anonymous"). About stars, reviews, etc... it's worth noting that barely anyone uses the star review system on spaceport. It seems to be around 1/1000 downloads. I don't see why this would change drastically on a better site, so I don't see much value in adding such a feature.