linuxgurugamer Posted June 10, 2016 Share Posted June 10, 2016 Subject says it. When staging, the parts which become the non-active vessel seem to get renamed, with a suffix which indicates the type of vessel (ie: Ship, etc). Is there any easy way to prevent this from happening? Thanks Link to comment Share on other sites More sharing options...
Superfluous J Posted June 10, 2016 Share Posted June 10, 2016 I've never found one. A mod (or stock implementation) that allows you to name each "command" part in the VAB would probably do it. Link to comment Share on other sites More sharing options...
sarbian Posted June 10, 2016 Share Posted June 10, 2016 If only there was an interface called IVesselAutoRename that a PartModule could implement... If only. Link to comment Share on other sites More sharing options...
Superfluous J Posted June 10, 2016 Share Posted June 10, 2016 2 minutes ago, sarbian said: If only there was an interface called IVesselAutoRename that a PartModule could implement... If only. I poked into the config files for the command parts to see if "rename" was just a module on its own, and figured when I didn't find it that it was instead part of ModuleCommand, and before poking into THAT I came back here. I'll poke some more on that. Though a quick Google search for IVesselAutoRename is surprisingly sparse. This thread is the fourth hit on the page, even though the mention is minutes old. Of the 3 more relevant links, 2 deal with asteroids and one is a KSP Class Hierarchy page with links to a lot of these things but no link to IVesselAutoRename. So to most quickly answer: 6 hours ago, linuxgurugamer said: Is there any easy way to prevent this from happening? "No." Link to comment Share on other sites More sharing options...
linuxgurugamer Posted June 10, 2016 Author Share Posted June 10, 2016 1 hour ago, 5thHorseman said: I've never found one. A mod (or stock implementation) that allows you to name each "command" part in the VAB would probably do it. Funny you should say that, that is exactly what I'm writing: Persistent Dynamic Pod Names. Unfortunately, the game still appends the craft type to the name after staging, but only to the staged parts which are not active. My test case is the following stack: Top part: MK1 Command Pod Middle part: MK1-2 Command Pod Bottom: PPD-12 Cupola Each separated from the other by a stack separator. Set the staging to go from bottom to stop, then launch the ship. Stage everything, then look at the ship names. The bottom one will have "Lander" appended, the other two will have "Ship" appended 1 hour ago, sarbian said: If only there was an interface called IVesselAutoRename that a PartModule could implement... If only. @sarbian I saw that, but don't know enough about c# to understand it properly. Right now my code inherits PartModule, if I also inherit the IVesselAutoRename, and implement the "GetVesselName", will that override stock? I'll do some digging, but if you could point me to an example, that would help. Thanks Link to comment Share on other sites More sharing options...
linuxgurugamer Posted June 10, 2016 Author Share Posted June 10, 2016 I have more to learn, but: I added the IVesselAutoRename to my PartModule class, and it seemed to work: public class PersistentDynamicPodNames: PartModule, IVesselAutoRename Still a bit concerned that it might be called multiple times for the same ship, especially if the ship has multiple command pods in the inactive section, but testing will show me what happens. Any additional pointers would help @sarbian, but thanks 1 hour ago, 5thHorseman said: So to most quickly answer: 8 hours ago, linuxgurugamer said: Is there any easy way to prevent this from happening? "No." Ummm, "Yes", thanks to @sarbian and some research Link to comment Share on other sites More sharing options...
Superfluous J Posted June 10, 2016 Share Posted June 10, 2016 10 minutes ago, linuxgurugamer said: Ummm, "Yes", thanks to @sarbian and some research I was speaking more for myself, as "easy" is relative Link to comment Share on other sites More sharing options...
JPLRepo Posted June 10, 2016 Share Posted June 10, 2016 In you implement IVesselAutoRename in your partmodel you can set GetVesselName to the name you want your vessel to have. Vessel.AutoRename will use that instead of the derived vessel name on decoupling. Least that is my understanding. Link to comment Share on other sites More sharing options...
linuxgurugamer Posted June 11, 2016 Author Share Posted June 11, 2016 On 6/10/2016 at 6:25 PM, JPLRepo said: In you implement IVesselAutoRename in your partmodel you can set GetVesselName to the name you want your vessel to have. Vessel.AutoRename will use that instead of the derived vessel name on decoupling. Least that is my understanding. Already done, thanks. I just have to learn some more about c# Interfaces Link to comment Share on other sites More sharing options...
linuxgurugamer Posted June 14, 2016 Author Share Posted June 14, 2016 (edited) On 6/10/2016 at 5:20 AM, sarbian said: If only there was an interface called IVesselAutoRename that a PartModule could implement... If only. @sarbian A question about this: I first implemented it using the following code: public class PersistentDynamicPodNames: PartModule, IVesselAutoRename { and the functions work properly. In fact, I noticed that even when there were multiple parts with this module, the function was only called one time. I then wanted to refactor my code, and tried making it as part of a new vesselmodule class: public class PDPNVesselModule : VesselModule, IVesselAutoRename { but the GetVesselName doesn't get called in this class. I did verify that the class is instantiated, and even that the FixedUpdate function which I put there as a test was being called. I did try to disable the functions in the partmodule, but that didn't help So what am I missing, why does it work when it's attached to a PartModule, but not to a VesselModule? thanks in advance Edited June 14, 2016 by linuxgurugamer Link to comment Share on other sites More sharing options...
Padishar Posted June 14, 2016 Share Posted June 14, 2016 (edited) 2 hours ago, linuxgurugamer said: So what am I missing, why does it work when it's attached to a PartModule, but not to a VesselModule? Because the game only calls it on PartModules that implement the interface... If you actually mean "Why does the game only call it on PartModules that implement the interface?" then you would need to ask a Squad developer, preferably the one that originally implemented it if they're still around. I haven't looked through any older versions to be certain but, since ModuleAsteroid is the only stock class that implements it (so that unclawed asteroids revert to their asteroid name rather than becoming "MyFunkyAsteroidTug-Ship"), I suspect that it was actually added in 0.23.5 (the ARM update) which was well before VesselModule existed... Edit: I also suspect there is a quirk to how it is called, e.g. it is only called on the first part in each new vessel that is created. This would work fine for asteroids. So, depending on the tree-structure of your vessel and which part(s) has the PartModule that implements it, you may find it doesn't always get called. For example, if you build: Pod Decoupler Fuel tank Probe core Fuel tank Engine ...and have all pods and probe cores implement it then you may find that it doesn't get called on the Probe core when you decouple and the game instead checks the top fuel tank to see if any of its modules implement it... Edit 2: Actually, it's "probably" better than I expected. It should call the GetVesselType function on every PartModule (that implements the interface) in the vessel, sort them in descending order of vessel type and then call GetVesselName on the "first" one... Edited June 14, 2016 by Padishar Link to comment Share on other sites More sharing options...
brusura Posted June 14, 2016 Share Posted June 14, 2016 Hope you find a solution @linuxgurugamer this is one thing I am looking for a fix for so long. Good Luck Link to comment Share on other sites More sharing options...
linuxgurugamer Posted June 14, 2016 Author Share Posted June 14, 2016 15 minutes ago, Padishar said: Because the game only calls it on PartModules that implement the interface... If you actually mean "Why does the game only call it on PartModules that implement the interface?" then you would need to ask a Squad developer, preferably the one that originally implemented it if they're still around. I haven't looked through any older versions to be certain but, since ModuleAsteroid is the only stock class that implements it (so that unclawed asteroids revert to their asteroid name rather than becoming "MyFunkyAsteroidTug-Ship"), I suspect that it was actually added in 0.23.5 (the ARM update) which was well before VesselModule existed... Edit: I also suspect there is a quirk to how it is called, e.g. it is only called on the first part in each new vessel that is created. This would work fine for asteroids. So, depending on the tree-structure of your vessel and which part(s) has the PartModule that implements it, you may find it doesn't always get called. For example, if you build: Pod Decoupler Fuel tank Probe core Fuel tank Engine ...and have all pods and probe cores implement it then you may find that it doesn't get called on the Probe core when you decouple and the game instead checks the top fuel tank to see if any of its modules implement it... :-( Ok, so at least I know what's going on. I know how to work around this, just makes the code a little messier Thanks Link to comment Share on other sites More sharing options...
Padishar Posted June 14, 2016 Share Posted June 14, 2016 (edited) 2 minutes ago, linuxgurugamer said: Ok, so at least I know what's going on. I know how to work around this, just makes the code a little messier See my second edit, makes life a bit easier, at least you may not have to add a PartModule to every part just in case... Edited June 14, 2016 by Padishar Link to comment Share on other sites More sharing options...
linuxgurugamer Posted June 14, 2016 Author Share Posted June 14, 2016 13 minutes ago, brusura said: Hope you find a solution @linuxgurugamer this is one thing I am looking for a fix for so long. Good Luck The solution will be to have the code in the PartModule actually call the code in the VesselModule. It's a hack, but will work. Keep an eye on my posts re: PersistentDynamicPodNames, I hope to release in one to two weeks, and it will have a solution implemented Link to comment Share on other sites More sharing options...
linuxgurugamer Posted June 14, 2016 Author Share Posted June 14, 2016 1 hour ago, Padishar said: See my second edit, makes life a bit easier, at least you may not have to add a PartModule to every part just in case... I have to add a partmodule to every command pod anyway, this will just be a part of it. Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now