blowfish

[1.5.1] B9PartSwitch v2.5.1 (December 1)

Recommended Posts

B9 Part Switch

B9PartSwitch.svg CKAN-Indexed-brightgreen.svg KSP%20Version-1.5.1-orange.svg

About

B9 Part Switch is a plugin that allows mods to make parts switchable, similar to Firespitter and Interstallar fuel switchers.  This mod doesn't do anything by itself, but provides a way for other mods to enable switching. 

Features

  • Parts can switch their resources, models, stack nodes, textures, heat tolerance, surface attach position, crash tolerance, and many other fields
  • Mass and cost can be modified
  • Tanks used to switch resources are defined centrally to allow easy modification and minimal setup
  • Easy to read, easy to write configs
  • Configs are designed for easy patching by ModuleManager
  • Unlimited switchers can be defined on the same part, provided that they do not conflict

A6okhWM.png

Download

Download Latest Version from Github

Also available on CKAN

Latest development builds can be found here.  Please only download if you have a specific reason.  Development builds are not guaranteed to work.

Troubleshooting

If you are experiencing an issue, please read this topic, if you have not already, on how to get proper support. Incomplete support requests will not be processed. Most importantly, include logs.

Source

On Github

Requirements

Each release of B9PartSwitch is intended to be run with a particular version of KSP. Please only use that version. If you have an earlier version of KSP, find the correct download for that version.  All previous releases are listed here.

B9PartSwitch requires ModuleManager to work.

Documentation

Wiki in progress.  Feel free to contribute.

Changelog

Spoiler

v2.5.1

  • Moved stack nodes now respect scalerescaleFactor, and TweakScale
  • Moved surface attach node now respects scale and rescaleFactor
  • When only one subtype is present, disable switching GUI and display subtype title as non-interactable string
  • Downgrade incompatible resource switching module to a warning and disable B9 resource switching in that case
  • French localization

v2.5.0

  • Allow moving stack nodes
    • Within a SUBTYPE, NODE nodes take a name (node ID) and a position (x, y, z position of the node)
  • Fix log message for duplicated subtype names
  • Fix texture switching behaving weirdly when copying a part in the editor

v2.4.5

  • Fix issues with resource switching and stock delta-v simulation code
    • Exception when copying a part in the editor
    • Delta-v simulation was probably off as well

v2.4.4

  • Recompile against KSP 1.5.1
  • Downgrade certain fatal errors to warnings
    • The user will still get an on-screen message but it can be dismissed without closing the game
    • Duplicate subtype names is now only a serious warning
    • Subtype without a name is now only a serious warning

v2.4.3

  • Fix .version file again again

v2.4.2

  • Fix .version file again

v2.4.1

  • Fix .version file still saying KSP 1.4.5

v2.4.0

  • Recompile against KSP 1.5
  • Provide better context for fatal exceptions
  • A few incompatibilities that previously silently disabled functionality are now fatal errors
  • Add Spanish translation of built-in strings
  • Fire onPartResourceListChange when changing resources

v2.3.3

  • Recompile against KSP 1.4.5

v2.3.2

  • Recompile against KSP 1.4.4

v2.3.1

  • Fix ModuleJettison shroud disappearing in flight if used with a ModuleB9PartSwitch that affects drag cubes
  • Don't destroy info module in flight since that messes with module order

v2.3.0

  • Recompile against KSP 1.4.3
  • Remove a couple of hacky workarounds as fixes/improvements were added in KSP 1.4.3
  • Use resource display names rather than identifiers in module description
  • Extract all hard-coded UI strings into localization table

v2.2.2

  • Fix texture replacements getting locked in when loading a craft in the editor if a part up the hierarchy renders procedural drag cubes

v2.2.1

  • Recompile against KSP 1.4.2
  • Fix transforms incorrectly being disabled in the part icon if subtypes are in a particular order
  • Fix transform in a TEXTURE node looking for renderers in child transforms too

v2.2.0

  • Recompile for KSP 1.4.1

v2.1.1

  • Fix texture replacements being reset when drag cubes are rendered
  • Fix battery tank type having 100x too much electric charge, bring mass in-line with stock

v2.1.0

  • Add texture switching
    • Each subtype can now have TEXTURE nodes which take the following fields:
      • texture (required) - path to the texture you want to use, e.g. MyMod/Parts/SomePart/texture
      • currentTexture (optional) - name of the current texture (just the filename excluding the extension, not the full path).  Anything that does not have this as the current texture will be ignored.
      • isNormalMap (optional, default false) - whether the texture is a normal map or not (necessary due to KSP treating normal maps differently when they are loaded)
      • shaderProperty (optional) - name of the shader property that the texture sits on.  Default is _MainTex if isNormalMap = false or _BumpMap if isNormalMap = true.  For an emissive texture you would want _Emissive
      • transform (optional, can appear more than once) - names of transforms to apply the texture switch to
      • baseTransform (optional, can appear more than once) - names of transforms where the texture switch should be applied to them and all of their children
    • If no transform or baseTransform is specified, it will look for textures to switch on the entire part

v2.0.0

  • Only match on exact attach node id
  • When switching in flight, resources should always start empty
  • Allow individual subtypes to not allow switching in flight via allowSwitchInFlight field
  • Allow ModuleB9PartSwitch to have its GUI hidden if it has advancedTweakablesOnly = true and advanced tweakables are disabled
  • Better error handling if resource of tank type does not exist (show error dialog in game and force the user to quit)
  • Fix .version file not being able to be parsed by KSP-AVC
  • Move remote .avc file from bintray to s3
  • Add back assembly guid (accidentally removed a while ago)

v1.10.0

  • Add new GUI that allows selecting subtype from a list
  • Allow switching in flight via switchInFlight parameter (uses new GUI)

v1.9.0

  • Add stackSymmetry part field to subtypes

v1.8.1

  • Fix drag cubes being overwritten with defaults on root part in flight scene
  • Fix vessel disappearing from map view if root part has a switcher that affects drag cubes

v1.8.0

  • Recompile for KSP 1.3
  • Drag cube re-rendering now supports IMultipleDragCubes

v1.7.1

  • Fix an occasional NRE when building part info

v1.7.0

  • Allow "child" part switch modules to modify volume of "parent" module
  • Allow multiple modules to manage the same transform or node, only enable it if they all agree

v1.6.1

  • Switch percentFilled priority to resource -> subtype -> tank type -> 100% since resources can be overridden on individual subtypes now

v1.6.0

  • Allow tanks to be partially filled - percentFilled can be defined on the subtype, resource, or tank type (in decreasing order of priority), defaulting to completely full
  • Allow toggling resource tweakability in the editor - resourcesTweakable can be defined on the subtype or tank type (subtype takes priority), default is whatever the standard is for that resource
  • Allow RESOURCE nodes directly on the subtype
    • If the resource already exists on the tank, values defined here will override what is already on the tank (won't affect other subtypes using the same tank)
    • If it isn't already on the tank, it will be added (won't affect other subtypes using the same tank)
  • Add ModuleB9DisableTransform to remove unused transforms on models
  • Major internal changes

v1.5.3

  • Recompile against KSP 1.2.2
  • Remove useless warnings in the log
  • A few internal changes

v1.5.2

  • Recompile against KSP 1.2.1

v1.5.1

  • Fix resource amounts displaying incorrectly in part tooltip
  • Reformat module title in part list tooltip a bit
  • Hopefully reduce GC some more

v1.5.0

  • Update for KSP 1.2
  • Add CoMOffset, CoPOffset, CoLOffset, CenterOfBuoyancy, CenterOfDisplacement to editable part fields
  • Hopefully reduce GC allocation a little bit

v1.4.3

  • Recompile against KSP 1.1.3
  • Remove some code which is unnecessary in KSP 1.1.3

v1.4.2

  • Fix TweakScale interaction - resource amounts did not account for scaling (broken since v1.4.0)

v1.4.1

  • Fix bug where we were setting maxTemp when we should have been setting skinMaxTemp or crashTolerance

v1.4.0

  • Find best subtype intelligently
    • If subtype name was previously set, use it to find the correct subtype (allows subtypes to be reordered without breaking craft)
    • If name was not previously set or not found, but index was, use it (this allows transitioning from current setup and renaming subtypes if necessary)
    • If index was not previously set, try to infer subtype based on part's resources (this allows easy transitioning from a non-switching setup)
    • Finally, just use first subtype
  • Add unit testing for subtype finding
  • Get rid of some unnecessary logging in debug mode
  • Refactor part switching a bit

v1.3.1

  • Fix bug where having ModuleB9PartInfo on a root part would cause physics to break due to an exception (really a stock issue but no sense waiting for a fix)

v1.3.0

  • Do not destroy incompatible fuel switchers.  Instead, disable fuel switching
  • Allow part's crash tolerance to be edited
  • Add info module to display changes to part in the info window.  Only displays things that can be changed.
  • Various internal changes

v1.2.0

  • Support TweakScale integration
  • Allow plural switcher description (in part catalog) to be edited)
  • Disable changing surface attach node size (problematic with Tweakscale)

v1.1.4

  • Don't remove FSfuelSwitch or InterstellarFuelSwitch if ModuleB9PartSwitch doesn't manage resources
  • Defer rendering drag cubes until part has been attached (fixes flickering in editor)
  • Avoid firing events multiple times
  • Various internal changes

v1.1.3

  • Recompile against KSP 1.1.2
  • Simplify part list info a bit
  • Hopefully make some error messages clearer
  • Various internal refactors and simplifications

v1.1.2

  • Remove FSmeshSwitch and InterstellarMeshSwitch from incompatible modules
  • Recompile against KSP 1.1.1

v1.1.1

  • Fix resource cost not accounting for units per volume on tank type

v1.1

  • KSP 1.1 compatibility
  • Fixed bug where having part switching on the root part would cause physics to break
  • Moved UI controls to UI_ChooseOption
  • Adjust default Monopropellant tank type to be closer to (new) stock values
  • Use stock part mass modification
  • Hopefully fix incompatible module checking
  • Various refactors and simplifications which might improve performance a bit

v1.0.1

  • Fix NRE in flight scene

v1.0.0

  • Initial release

License

B9PartSwitch is licensed under the GNU Lesser General Public License Version 3.0

Authors

@blowfish Main developer

@bac9 author of Part Subtype Switcher, upon which this is heavily based

And all others who have submitted fixes and enhancements

Edited by blowfish
  • Like 16

Share this post


Link to post
Share on other sites

Thank you for making a separate thread for just the part switcher. When I first saw mods that I use start to switch to B9 (quite recently), I really enjoyed it. I think it looks cleaner and is better than the IFS/Firespitter, although I like all three.

Thanks. :)

Edited by KocLobster

Share this post


Link to post
Share on other sites

After I updated to 1.3.0 my loaded craft with many procedural tanks, thrust plates and fairings is ripped apart with huge gaps and I can't reattach because the nodes are in the middle of the parts or nonexistant ...

Log:
https://www.dropbox.com/s/zcwaqcxeq7m52yf/2016-05-27-1%20B9PartSwitch%20update%20broke%20procedural%20parts%20craft.7z?dl=0

Edited by Gordon Dry

Share this post


Link to post
Share on other sites
11 minutes ago, Gordon Dry said:

After I updated my loaded craft with many procedural tanks, thrust plates and fairings it is ripped apart with huge gaps and I can't reattach because the nodes are in the middle of the parts or nonexistant ...

Log:
https://www.dropbox.com/s/zcwaqcxeq7m52yf/2016-05-27-1%20B9PartSwitch%20update%20broke%20procedural%20parts%20craft.7z?dl=0

And are any of the parts in question actually using B9PartSwitch?  It has nothing to do with procedural parts.  Looking at your logs (good that you provided them regardless), I don't see you ever placing a part that uses B9PartSwitch.

Share this post


Link to post
Share on other sites

Darn. It's so hard to find a culprit, yesterday I saved the craft, launched it and now it's like that.
Okay, I will check further....

Share this post


Link to post
Share on other sites

Just curious, has anyone heard of this mod causing problems with the EAS-1 External Command Seat (stock part)? I've spent the last week trying to track down which of my 120+ mods was causing my kerbals to stand in the place of the seat when I tried to board them to it. They would be standing there instead of sitting, and would walk in place when I tried to move them, stuck to the seat, with no way (short of editing the persistence file) to get them back out. I tried uninstalling mods which made sense, like Take Command and a few others that were obvious choices, but had no luck. I finally decided to start installing the mods one at a time in a clean KSP installation to find the culprit. B9PartSwitch passed that test. After going through every mod and not finding one that caused the issue, I tried the modded install again. Again, the problem was there. I loaded CKAN, and it showed an update for this mod. I downloaded it, then went back to work on a design I was working on before this problem was noticed. On a wild hair, I decided to test the EAS-1 again, and now it is working correctly. The only thing that changed between my last failed test and the working one was B9PartSwitch updating. I didn't think this did anything with the EAS-1, but as I said, this was the only change that occurred before the problem was corrected.

Share this post


Link to post
Share on other sites

@kananesgi Shouldn't be.  This mod will only affect parts that have ModuleB9PartSwitch (which is none if you don't install another mod that actually uses it).

Share this post


Link to post
Share on other sites

Hmm, that is interesting then. I wonder if some other mod that uses B9PartSwitch was somehow causing a conflict and the update for this resolved it. A mystery...

Share this post


Link to post
Share on other sites
1 hour ago, kananesgi said:

Hmm, that is interesting then. I wonder if some other mod that uses B9PartSwitch was somehow causing a conflict and the update for this resolved it. A mystery...

Possible, but unlikely.  There are only a few mods using B9PartSwitch right now, and to my knowledge none of them modify the command seat (and why would they?).  If you want to determine the responsible mod, you probably have to do a binary search through your mods - disable half of them, see if that fixes it, if not it's in the other half, keep narrowing down by half until you isolate the mod responsible.

Share this post


Link to post
Share on other sites
1 hour ago, blowfish said:

Possible, but unlikely.  There are only a few mods using B9PartSwitch right now, and to my knowledge none of them modify the command seat (and why would they?).  If you want to determine the responsible mod, you probably have to do a binary search through your mods - disable half of them, see if that fixes it, if not it's in the other half, keep narrowing down by half until you isolate the mod responsible.

I like this, this technique works well for me.

Share this post


Link to post
Share on other sites

@blowfish

quick question for you: is the moduleID always "fuelSwitch" when ModuleB9PartSwitch is in the role of switching fuel? I ask because I'm making a patch that applies GPO Speed Fuel Pump to parts with B9 fuel switching capability. Previously, I just blanket targeted the module itself, but I'm interested in making it a little more precise (since I'm assuming, like other Switchers, it isn't exclusive to fuel). Just wondering if that's a hard and fast rule I can work from (looking at B9 and CryoTanks seems to suggest as much).

Cheers.

Share this post


Link to post
Share on other sites
31 minutes ago, Deimos Rast said:

@blowfish

quick question for you: is the moduleID always "fuelSwitch" when ModuleB9PartSwitch is in the role of switching fuel? I ask because I'm making a patch that applies GPO Speed Fuel Pump to parts with B9 fuel switching capability. Previously, I just blanket targeted the module itself, but I'm interested in making it a little more precise (since I'm assuming, like other Switchers, it isn't exclusive to fuel). Just wondering if that's a hard and fast rule I can work from (looking at B9 and CryoTanks seems to suggest as much).

Cheers.

The only requirement on moduleID is that each ModuleB9PartSwitch has a unique value.  It can be blank if there's only one module.  I have definitely tried to use conventions throughout B9.

If you're trying to identify parts with fuel switching capability, I would recommend :HAS[#baseVolume[>0]] - that's what I use in B9's own RF/MFT patches.

  • Like 1

Share this post


Link to post
Share on other sites
40 minutes ago, blowfish said:

The only requirement on moduleID is that each ModuleB9PartSwitch has a unique value.  It can be blank if there's only one module.  I have definitely tried to use conventions throughout B9.

If you're trying to identify parts with fuel switching capability, I would recommend :HAS[#baseVolume[>0]] - that's what I use in B9's own RF/MFT patches.

yeah, I thought that was the case, but I couldn't think of a better way and I was hoping it wouldn't bite me. I like your suggestion better, and I found the patch you mentioned; thanks.

Share this post


Link to post
Share on other sites

I'm having an issue with this mod interacting with, I think, Fuel Tanks Plus by @NecroBones or NFE by @Nertea. Recently I've been launching ships and when i switch back to them later they end up just showing a single part floating in space. This can be as fast as a quick hop to the space centre and back.Without B9PartSwitch installed the ship sites happy in orbit. As soon as I install it however the ship fails.

ship1.jpg?dl=0This ship Link here Sites happily in orbit and consists of a clamp-o-tron, and FTP X200 - 08 Adaptor, an MRS 2.5m reaction wheel, and X200-48 fuel tank, and a NFE kerbopower reactor. 

Once PartSwitch is installed This happens and I am left with this tank floating in space. This tank was the root part of the vessel. I've tagged Nertea and NeroBones both as I'm not sure exactly where the fault is sitting. I'm not sure FTP has anything to do with PartSwitcher but I have another ship in orbit built with stock tanks and a Kerbopower reactor that has not been affected by this error suggesting its the tanks, not the reactor. Likewise the other vessel had a NFShips orbital command pod and has not been touched.

Is there anything any of you fine gentlemen can think might be causing this? 

This is my current AVC list (yes I know CC is out of date, while troubleshooting I appear to have installed an out of date version) 

This is my Output Log.

If there is any more info you need let me know, this is somewhat game breaking atm and if it can be resolved I'd be grateful!

Thanks

Mal

Share this post


Link to post
Share on other sites

@Malich I'm away from home for a few days but feel free to remind me on Tuesday or so if I don't get back by then.

Share this post


Link to post
Share on other sites

@Malich I found a bit of time to look for your log.  I'm not quite sure what's causing that weird thing in the background but I did find a couple of errors on the FTP parts ( pinging @NecroBones )

Spoiler

Warning on PartSubtype Delta on module ModuleB9PartSwitch (moduleID='meshSwitch') on part TPtank2mL00469: No transforms named TPtank2m-Orange2 found

Warning on PartSubtype Titan on module ModuleB9PartSwitch (moduleID='meshSwitch') on part TPdecoupler3m: No transforms named TPtank3m-Silver found

Warning on PartSubtype STS on module ModuleB9PartSwitch (moduleID='meshSwitch') on part TPdecoupler3m: No transforms named TPtank3m-Orange found

Warning on PartSubtype STS on module ModuleB9PartSwitch (moduleID='meshSwitch') on part TPdome3m: No transforms named TPtank3m-Orange found

Warning on PartSubtype Titan on module ModuleB9PartSwitch (moduleID='meshSwitch') on part TPtank3mL00938: No transforms named TPtank3m-Silver found

Warning on PartSubtype STS on module ModuleB9PartSwitch (moduleID='meshSwitch') on part TPtank3mL00938: No transforms named TPtank3m-Orange found

I also see a couple of exceptions related to Kerbal Alarm Clock.

 

  • Like 1

Share this post


Link to post
Share on other sites

@blowfish, The weird thing in the background is Kerbin believe it or not. Thanks for taking a look at this, appreciated. I'll wait to see if NecroBones chimes in but for now I'll probably drop FTP from my mods and work it back in when there's a solution.

Share this post


Link to post
Share on other sites

 

No idea why it wouldn't find those transforms.

 

I did just release an update to FTP to make the fuel and mesh switcher rules prioritize the switcher mods the same as each other. It's possible that a mixed-switcher thing was goofing things up.

 

Share this post


Link to post
Share on other sites
17 hours ago, blowfish said:

B9PartSwitch v1.3.1 is now Available

Fixes a bug where having info module on a root part would cause physics to break due to an exception (really a stock issue but no sense waiting for a fix)

Here I was thinking the Kraken had compressed my space probe into a space tuna can, but it turns out I had set a switchable fuel tank as the root part and this update fixed it - in flight. Thanks!

Share this post


Link to post
Share on other sites

This mod can used to change only de textures on a model? and how I do that? I made 3 reskins to procedural fairing and want to use a mod to change the textures

sry my english and thanks in advance

Share this post


Link to post
Share on other sites
1 hour ago, gilbr0ther said:

This mod can used to change only de textures on a model? and how I do that? I made 3 reskins to procedural fairing and want to use a mod to change the textures

sry my english and thanks in advance

Texture swapping isn't currently supported, sorry.  At least not directly.  I know there are other mods that add reskinned procedural fairings, but they display as separate parts.  You might want to have a look at some of those.

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, blowfish said:

Texture swapping isn't currently supported, sorry.  At least not directly.  I know there are other mods that add reskinned procedural fairings, but they display as separate parts.  You might want to have a look at some of those.

thanks

Share this post


Link to post
Share on other sites

B9PartSwitch v1.4.0 is now Available

The main change in this update is that the subtype is now inferred intelligently.  Previously only the index was used, which could lead to a bunch of craft breaking scenarios.  Here are some of the benefits:

For Players

When moving from a non-switching setup to a switching setup, or when using a switching setup from a different author, craft will generally not break because the subtype can be inferred based on the part's resources

For Modders

You can now reorder subtypes without breaking craft files, since the subtype name is the primary way of identifying the subtype.

The full details of how this works are in the changelog.

  • Like 1

Share this post


Link to post
Share on other sites

@blowfish I believe I have tracked down a nasty little bug in v1.4.0.  I've had some problems with parts exploding instantly the moment I placed them on the launchpad.  It seems there was a bug introduced in the following commit related to managing crash tolerance, except that you are accidentally setting maxTemp instead.  Additionally, it appears that the same problem may exist for skinMaxTemp just above it.

Github Commit: https://github.com/blowfishpro/B9PartSwitch/commit/717d81dcf48c66559adf2aa96816535ae97af85a

Look at lines 492 - 495 (shown below) in method UpdatePartParams() of file ModuleB9PartSwitch.cs:

if (CrashToleranceManaged)
{
    part.maxTemp = (CurrentSubtype.crashTolerance > 0f) ? CurrentSubtype.crashTolerance : part.GetPrefab().crashTolerance;
}

I'm figuring this should say "part.crashTolerance = " instead of "part.maxTemp = ".

  • Like 2

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now