Mihara

[0.24.2] JSIPartUtilities -- a mishmash of clever things to do with parts.

Recommended Posts

mod edit

A new fork is available here:

I've locked this thread for now. Go there for the new version.

/mod edit

A Note on 0.90.0 Compatibility:

In Mihara's absence, artwhaley has kindly recompiled fixed versions of the JSIPartUtilies DLL for KSP 0.90.0 - download links are available here.


This is a collection of PartModules that I made mostly for solving various problems posed by alexustas while he was making KONQUEST, and will eventually be both bundled with it and published separately for general use.

In particular, he wanted to be able to select between multiple part configurations while in the VAB, but obviously, it didn't stop there. Right now, the plugin can:

  1. Toggle meshes and colliders on and off both in the VAB and out of it.
  2. Track animation states to do same. (In the particular case it was used for, a wheel collider remains inactive up until the animation that extends the wheel finishes playing.)
  3. Try to toggle other PartModules on and off. (Doesn't work for all cases)
  4. Swap shaders and textures on meshes, alter a number of other parameters like mass and cost.
  5. Give you much more options when decorating stuff with flags.
  6. Replicate the function of Reflaginator -- but working properly with agency flags. :)

License is GPLv3, source code is on GitHub, full documentation is available on GitHub in my usual style, downloads are on the GitHub releases page, current as-it-happens dev build is on the front page of the wiki.

It probably doesn't work particularly well yet, but I figure it's time to show it to people at large and ask them to poke holes in it, because I want it to be as much a useful tooklit as RPM is. :)

Share this post


Link to post
Share on other sites
you make too many toys! :D

In particular, I've just made that select-between-multiple-groups feature I mentioned which needs testing. :)

Share this post


Link to post
Share on other sites

spent a day wondering why globalButtons weren't working on MFD... tried different collider names, button names, different exports. now I saw I had commented out the globalButtons line. LOL

Share this post


Link to post
Share on other sites

I did get crew capacity control to work. Somewhat.

I can't prevent you from launching a module with kerbals in it that shouldn't be there (unless I can figure out a way to kick them out before the launch) but making a module that won't let kerbals in until it lands should now be feasible. :)

Share this post


Link to post
Share on other sites

How very dare you! :)

I totally had no idea you posted to my Reflaginator thread otherwise I would have said something. it's my fault for not subbing to my very own thread. Now I can let that one die then. Thanks!

Share this post


Link to post
Share on other sites
I totally had no idea you posted to my Reflaginator thread otherwise I would have said something. it's my fault for not subbing to my very own thread.

Oh well. :)

Meanwhile, wooo, I sorted out kicking kerbals out of the part on launch. :) This plugin is now suitable for use in making foolproof inflatable habitats, (you can even remove the collider on the hatch) and in a while, it should become suitable for use in making habitats which are only accessible when landed.

Share this post


Link to post
Share on other sites

Nice. Question, toggling PartModules, that includes custom ones as well from mods?

Share this post


Link to post
Share on other sites
Nice. Question, toggling PartModules, that includes custom ones as well from mods?

That includes any PartModule, however, whether it works or not is a tossup .

Unity offers a specific flag for making a MonoBehaviour disabled -- it's called 'enabled' and setting it to 'false' makes sure this module does not get called in Update() or most anywhere else. (It also triggers a call to it's OnEnabled/OnDisabled, if my memory serves me right). But that's not enough to shut a PartModule down. :) That's because KSP has it's own update routines -- a PartModule's OnUpdate() is called independently of Unity's Update() by part's Update(). However, that has it's own disable flag, 'isEnabled'. Setting it to false will prevent a PartModule's OnUpdate from happening.

...But even that isn't enough to completely shut a module down. :) If it has any KSPEvents, or hooks into any GameEvents, as far as I can tell, it will get called anyway, with no checks. There's no way to disable that, as far as I can tell, without going through it's events and shutting them all down too. But then, making sure they're correctly reenabled when needed becomes a royal pain, which is why I'm not doing that.

Which is why some modules can be disabled this way, some can't, and there's no telling without trying.

Share this post


Link to post
Share on other sites

Interesting. I'll have to mess around with this one.

Share this post


Link to post
Share on other sites

PartModule Toggle doesn't seem to work on JSITransparentPod or ModuleRCS.

SelectableFlag works fine with TweakScale mod. :) though the $RANDOM$ flag doesn't seem to do anything. full path to specific flag works fine.

Share this post


Link to post
Share on other sites

I'm having a bit of trouble, perhaps you can provide some insight?

MODULE
{
name = JSIPartComponentGroup
componentToggles = leftWingComponent
managedNodes = left
areComponentsEnabled = true
persistAfterEditor = false
activeInEditor = true
activeInFlight = false
showEnableDisableOption = false
showToggleOption = true
toggleMenuString = Toggle Left Extention
}

Where does the managedNodes get the node names from? I've tried just generic "left", but the attachnode still remains active when toggled. The attachnode is simply:

node_stack_left = -1.475, 0, 0, 1, 0, 0, 1

Share this post


Link to post
Share on other sites

Where does the managedNodes get the node names from? I've tried just generic "left", but the attachnode still remains active when toggled. The attachnode is simply:

node_stack_left = -1.475, 0, 0, 1, 0, 0, 1


/ --- node definitions ---
// definition format is Position X, Position Y, Position Z, Up X, Up Y, Up Z

node_stack_WR1 = 0.761279, 0.23125, 0.8580958, 1, 0, 0, 2
node_stack_WL1 = -0.761279, 0.23125, 0.8580958, -1, 0, 0, 2
node_stack_WR2 = 0.761279, -0.23125, 0.8580958, 1, 0, 0, 2
node_stack_WL2 = -0.761279, -0.23125, 0.8580958, -1, 0, 0, 2
node_stack_m1 = 0, 0, -0.669374, 0, 0, 1.0, 2
node_stack_t = 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 2
node_stack_b= 0.0, -0.5, 0.0, 0.0, 1.0, 0.0, 2
node_attach = 0, 0, -0.669374, 0, 0, 1.0, 2

...


//----------------- NODES MANAGEMENT ---------------------------

//----------------- TOP NODE -----------------------------------
MODULE
{
name = JSIPartComponentGroup
groupID = TopNode
areComponentsEnabled = true
persistAfterEditor = false
activeInEditor = true
activeInFlight = false
enableMenuString = - TOP Nodes
disableMenuString = + TOP Nodes
showToggleOption = false
managedNodes = m1
}

//----------------- BACK NODE -----------------------------------
MODULE
{
name = JSIPartComponentGroup
groupID = BackNode
areComponentsEnabled = true
persistAfterEditor = false
activeInEditor = true
activeInFlight = false
enableMenuString = - BACK Nodes
disableMenuString = + BACK Nodes
showToggleOption = false
managedNodes = b
}

//----------------- WHEEL FRONT NODES -----------------------------------

MODULE
{
name = JSIPartComponentGroup
groupID = WheelFrontNodes
areComponentsEnabled = true
persistAfterEditor = false
activeInEditor = true
activeInFlight = false
enableMenuString = - FRONT WHEEL Nodes
disableMenuString = + FRONT WHEEL Nodes
showToggleOption = false
managedNodes = WR1|WL1
}
//----------------- WHEEL BACK NODES -----------------------------------

MODULE
{
name = JSIPartComponentGroup
groupID = WheelBackNodes
areComponentsEnabled = true
persistAfterEditor = false
activeInEditor = true
activeInFlight = false
enableMenuString = - BACK WHEEL Nodes
disableMenuString = + BACK WHEEL Nodes
showToggleOption = false
managedNodes = WR2|WL2
}

Share this post


Link to post
Share on other sites

Thanks Alexus,

After copying your code directly, and still not having it work, I knew there was something else wrong. The link to the github in the OP seems to be out dated. I compared it to another JSIPartUtilities in another mod (properties showed version 0.2.84, the one in the OP shows version 0.2). I used the dll 0.2.84 from the other mod and it started working.

Share this post


Link to post
Share on other sites
Could someone please show an example of how to toggle resources? The documentation is a little hard to follow.

I had this figured out before, but since my home computer is currently down, I can't check the working example.

But, if I recall, I used JSIPartComponentGroup with the actuator managedResource. From what I remember, the JSIPartComponentGroup module MUST be declared before the Resource module. Also, it only works in the VAB/SPH and not while in flight.

Share this post


Link to post
Share on other sites
That's marginally more helpful. I'll see what I can do.

Is anyone having problems with this in 0.25?

I'm using JSI to toggle meshes and nodes. That is working fine in 0.25.

Share this post


Link to post
Share on other sites

Is it possible to switch fuel tank sizes with this? The idea is to have a single fuel tank part per diameter and to scale it (by switch models) to change the length of the tank, I tried checking firespitter but it doesn't support attachment node changes and I was wondering if this does.

Of course if this doesn't work then I'll just use tweak scale to change diameters instead of length and offer different lengths of fuel tanks instead of different diameters

Edited by mbartelsm

Share this post


Link to post
Share on other sites

Does this need updating for 0.90 as its a dependency for the ers rover and its not playing nicely with 0.90

Share this post


Link to post
Share on other sites

Hmmm...I'm having issues with the wheels with the ERS rover in 0.25...Also getting LOTS of wheel collider errs in my KSP log...I wonder if this is my problem?... Guess I may have to check what vers. JSI I have...

Share this post


Link to post
Share on other sites

This thingie is throwing exceptions on load, so it definitely needs an update. Here's the relevant bit:

[ERR 08:56:56.261] AssemblyLoader: Exception loading 'JSIPartUtilities': System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
at AssemblyLoader.LoadAssemblies () [0x00000] in <filename unknown>:0

Additional information about this exception:

System.TypeLoadException: Could not load type 'JSIPartUtilities.JSIPartComponentToggle' from assembly 'JSIPartUtilities, Version=0.0.1.0, Culture=neutral, PublicKeyToken=null'.

System.TypeLoadException: Could not load type 'JSIPartUtilities.JSIPartComponentGroup' from assembly 'JSIPartUtilities, Version=0.0.1.0, Culture=neutral, PublicKeyToken=null'.

System.TypeLoadException: Could not load type '<DelayedLoop>d__0' from assembly 'JSIPartUtilities, Version=0.0.1.0, Culture=neutral, PublicKeyToken=null'.

Share this post


Link to post
Share on other sites

Umm, since it's been a while, I just thought I'd mention that this still needs updating to 0.90. In case it's been forgotten. Hello? :confused:

Share this post


Link to post
Share on other sites

Mihara is very busy. RPM has been slow to get an official update. I'm sure he'll get to this when he gets a chance. But... given that people's interest in any game comes and goes... it's a little unreasonable for us to EXPECT someone to make time to push out an update every time this game updates. It's a hassle that comes with modding for a game that's still in development... but publishing a mod isn't a commitment to come back and figure out what's changed and recode the broken parts and compile and publish every two months when an update comes out. So... sometimes things will be broken for a while. Or forever.

I may take a look and see if recompiling against .90 just magically works. I'll post here if I find anything.

Art

Share this post


Link to post
Share on other sites

I attempted to do just that when .90 was still steaming from the press. There seems to be a specific function it makes use of that has been changed in the reference dll which requires more input than it did previously. This input is described, but my limited experience with C# has me scratching my head and getting nowhere.

It's really annoying since there are a few part packs out there that seem to revolve around this mod quite heavily.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.