Jump to content

[1.12.x] KSP Part Volumes


Recommended Posts

KSP_PartVolume 

This is a small mod which will add the ModuleCargoPart to all parts which don't already have it.  This is necessary in order to allow a part to be an inventory cargo part that can be placed in inventories or allowing larger parts to be manipulated in EVA construction mode (but not placeable in inventories)

It works by using the stock methods GetRendererBounds() to get the outermost bounds of the part.

Usage

  1. Install the mod using either CKAN or a manual install. 
  2. The first time the game is run, a file will be created in the GameData directory called partVolume.cfg
  3. The changes will be applied on the fly when first run, and also written to a config file.  If you aren't changing your mod mix, you can remove this after the first run, and the config file will remain and apply the changes during the initial ModuleManager run

 

 

Settings
A toolbar button will be visible in the upper right when at the MainMenu.  Click the button to open a Settings window:

LIc8yk4.png

 

Filler is a default amount of extra volume used for packing and storage.  There are several different filler settings, the settings are (with their defaults) as follows:

Part Type

Do Tanks (False) Create configs for tanks
Manned (False) Create configs for manned parts
Do Stock (False) Create configs for stock parts which don't have configs (includes expansions)
 Filler (10%) A default amount when no other applies
Science Filler (25%) Filler for science parts
Engine Filler (15%) Filler for engines
RCS Filler (20%) Filler for RCS parts
Limit Size (True)  Limit maximum size for a config to be applied (before filler adjustment)
Largest Allowable Part (64000 l)   Largest volume allowed if Limit Size is true

               

All filler percentages go from 0 to 100%.  In the event that more than one type of filler can apply to a part, only the largest will apply.

Part types are determined as follows:               

Part Type  
Science Part is listed in the config to be a PartCategories.Science part
Engine Part has either ModuleEngines or ModuleEnginesFX
RCS             Part has either ModuleRCS or ModuleRCSFX
Tank Part has resources and no other module (yes, this includes batteries
Manned         Part can hold crew

 

If any setting is changed and saved, the config file (GameData/partVolumes.cfg) is deleted and a popup is shown indicating that the game will need to be restarted:

wHBqHpd.png


All configs generated by this mod will only apply if a part does NOT have a ModuleCargoPart already defined.  This way mods can get updated by the author with their settings with no worry that their settings will be overridden.

Output

The generated file will contain the following information (example from KW Rocketry):

// KWRocketry/Parts/Aero/150mSRBTop/KW2mSRBNoseCone/KW2mSRBNoseCone
// Bounding Box Size: 3107.528 liters
// Volume adjustment: 15%
// Engine module detected
//
@PART[KW2mSRBNoseCone]:HAS[!MODULE[ModuleCargoPart]]:Final
{
    MODULE
    {
        name = ModuleCargoPart
        packedVolume = 3575
    }
}

The comments are provided for mod authors who might wish to use the calculated information in their own mods.  If a mod author does use this, please provide me with a small credit

Note

  • The generated config file is placed in the GameData directory so that the mod can be deleted without deleting the generated configs

Dependencies

Availability

Available via CKAN

Acknowledgments

Thanks to forum user @ValiZocktfor providing me with an initial implementation of the volume calculations, and again to him for pointing out the GetRendererBounds() method which greatly simplified the code

 

Edited by linuxgurugamer
Link to comment
Share on other sites

Absolutely awesome mod, exactly what the Doctor (von Kerman) ordered.

Would it be a long shot to bring up the consideration that the filler setting could in some situations be desirable to go <0?

Link to comment
Share on other sites

3 hours ago, Poodmund said:

Would it be a long shot to bring up the consideration that the filler setting could in some situations be desirable to go <0?

Ummm, like what?  In my mind, filler is packing material and whatever space is needed to keep things safe.  

Link to comment
Share on other sites

1 hour ago, Hohmannson said:

Like trusses/panels that can be considered assembled in situ, thus having less volume packed then unpacked.

I disagree.  If it was a box, then yes.  But panels are not boxes, and really won't change depending on if they are assembled or not

Link to comment
Share on other sites

Doesn't seem to handle part names with spaces in their name.

Specifically, in my case the following

// ----------------------------------------------------------------------
// kOS/Parts/KOSCherryLight/part/Cherry Light
// Bounding Box Size: 10.6532 liters
// Volume adjustment: 10%
//
@PART[Cherry Light]:HAS[!MODULE[ModuleCargoPart]]:Final
{
    MODULE
    {
        name = ModuleCargoPart
        packedVolume = 13
    }
}
// ----------------------------------------------------------------------

MM Syntax does not allow for spaces IIRC and so I get an MM error during load, and then KSP_PartVolume tries to add the Chery Light part again every restart so I end up with a bunch of duplicate entries at the end of my partVolumes.cfg file

I can post logs if you really need them but I'm guessing you don't.

Easy manual fix btw, just need to manual change the part name to remove the space, ofc will be overwritten on next mod update, so not ideal.

Edited by Coyote21
Link to comment
Share on other sites

Posted (edited)
1 hour ago, Coyote21 said:

I can post logs if you really need them but I'm guessing you don't.

Would have saved me time, I do need to see the error.  Also the MM cache.

But I've already gotten them.

Should be an easy fix, I'll just replace the spaces with periods or questionmarks, I'll verify which (that's a wildcard for mm, I believe)

Edited by linuxgurugamer
Link to comment
Share on other sites

1 minute ago, OrdinaryKerman said:

I thought it's "&" ?

From the MM manual:

Quote

<Name-With-Wildcards> : The name of the value you'll be messing with. Wildcards are not always available for every Op. Wildcards include ? for any character, and * for any number of chars. Note that ''only alphanumeric chars'' are allowed in value names for patches. If you have spaces or any other char, use a ? to match it

 

Link to comment
Share on other sites

1 hour ago, Coyote21 said:

Doesn't seem to handle part names with spaces in their name.

Spaces in part names, files, models, & folders is just really bad practice. I know, not your mod :P
 

Edited by Stone Blue
Link to comment
Share on other sites

New release, 0.0.1.1

  • Fixed issue where a partname with a space was causing a ModuleManager error.  Replaced spaces in partnames with questionmarks per the MM manual

Delete the file partVolumes.cfg in the GameData directory before rerunning again

Link to comment
Share on other sites

18 minutes ago, linuxgurugamer said:

Would have saved me time, I do need to see the error.  Also the MM cache.

OK, Sorry, I think I'll just get into the habit of ALWAYS posting logs from now on, seems I don't really know whether they are needed or not.

Link to comment
Share on other sites

20 minutes ago, Coyote21 said:

OK, Sorry, I think I'll just get into the habit of ALWAYS posting logs from now on, seems I don't really know whether they are needed or not.

theres a new mod that might help with that ;)

 

Edited by Stone Blue
Link to comment
Share on other sites

15 minutes ago, Coyote21 said:

OK, Sorry, I think I'll just get into the habit of ALWAYS posting logs from now on, seems I don't really know whether they are needed or not.

Yes, always a good idea.  Although to be honest, in this case would have saved me only about 5 minutes, since you had correctly identified the problem.

Link to comment
Share on other sites

18 hours ago, linuxgurugamer said:

Ummm, like what?  In my mind, filler is packing material and whatever space is needed to keep things safe.  

Just thinking for extensibility. Out of curiosity, how does the mod handle animation states for things like solar panels, ladders or antenna parts?

Link to comment
Share on other sites

18 minutes ago, Poodmund said:

Just thinking for extensibility. Out of curiosity, how does the mod handle animation states for things like solar panels, ladders or antenna parts?

It doesn't. It uses whatever drag cubes are present when the part is instantiated.  It really depends on how the game internally handles it.  I don't have time to test, but I would be interested in hearing if you find any issues with this

Link to comment
Share on other sites

On the first run it created empty partVolumes.cfg, and there weren't any popup warnings

I have a patch that make all parts manipulatable in the eva by adding ModuleCargoPart with a volume -1.
Do parts with the ModuleCargoPart appears in the output, but HAS[!MODULE[ModuleCargoPart]] make the MM ignore the patch
or the  parts with the ModuleCargoPart ignored whatsoever? The last case would explain why the output is empty. 

ksp.log: https://1drv.ms/u/s!Alncj27YxKc-hm1M2fbnCOesw2g7?e=7z5xRA
player.log: https://1drv.ms/u/s!Alncj27YxKc-hm5H70FdGFno1NP_?e=JAWAdS

 

Edited by flart
Link to comment
Share on other sites

Really like the idea of this mod, much more sensible than KIFA, seems to me.

Couple things I've noticed so far:

1. The "include tanks" radio button setting does not hold between restarts; I think it actually does apply the patches, but the button itself doesn't remain checked

2. It takes two restarts to apply patches if settings are changed (e.g. include tanks) - it seems like you then need to start up, change settings, then restart to generate the patch that corresponds to those new settings. Then KSP Part Volumes tells you you need to restart again to apply the patch just generated.

Fantastic mod!

Edited by AccidentalDisassembly
Link to comment
Share on other sites

6 hours ago, flart said:

On the first run it created empty partVolumes.cfg, and there weren't any popup warnings

I have a patch that make all parts manipulatable in the eva by adding ModuleCargoPart with a volume -1.
Do parts with the ModuleCargoPart appears in the output, but HAS[!MODULE[ModuleCargoPart]] make the MM ignore the patch
or the  parts with the ModuleCargoPart ignored whatsoever? The last case would explain why the output is empty. 

ksp.log: https://1drv.ms/u/s!Alncj27YxKc-hm1M2fbnCOesw2g7?e=7z5xRA
player.log: https://1drv.ms/u/s!Alncj27YxKc-hm5H70FdGFno1NP_?e=JAWAdS

 

That will disable this mod.  This mod will NOT do anything to any part that has a ModuleCargoPart, if there is one, nothing is generated.

1 hour ago, AccidentalDisassembly said:

The "include tanks" radio button setting does not hold between restarts; I think it actually does apply the patches, but the button itself doesn't remain checked

I'll check that

1 hour ago, AccidentalDisassembly said:

It takes two restarts to apply patches if settings are changed (e.g. include tanks) - it seems like you then need to start up, change settings, then restart to generate the patch that corresponds to those new settings. Then KSP Part Volumes tells you you need to restart again to apply the patch just generated.

Yes, that's the way it works. First run after any change it generates the patch file, needs to be restarted for the patch to take effect

Link to comment
Share on other sites

3 minutes ago, linuxgurugamer said:

That will disable this mod.  This mod will NOT do anything to any part that has a ModuleCargoPart, if there is one, nothing is generated.

I'll check that

Yes, that's the way it works. First run after any change it generates the patch file, needs to be restarted for the patch to take effect

I mean to say: after changing settings, you need to restart to generate the patch file, which seems to be generated after parts load. (Maybe?) Then restart *again* to have the patches applied by MM - two restarts in total. That's what the dialog boxes suggested needed to happen, at any rate...

EDIT: I am dense. You are saying what I am saying.

Edited by AccidentalDisassembly
Link to comment
Share on other sites

New release, 0.0.1.2

  • Fixed the saving/loading of the DoTanks option
1 minute ago, AccidentalDisassembly said:

I mean to say: after changing settings, you need to restart to generate the patch file, which seems to be generated after parts load. (Maybe?) Then restart *again* to have the patches applied by MM - two restarts in total. That's what the dialog boxes suggested needed to happen, at any rate...

Yes.  That's what you have to do, which is why I have those dialog boxes since it really isn't intuitive.  But adding it to the AvailableParts at runtime to avoid the second restart was problematic, to say the least

Link to comment
Share on other sites

2 minutes ago, linuxgurugamer said:

New release, 0.0.1.2

  • Fixed the saving/loading of the DoTanks option

Yes.  That's what you have to do, which is why I have those dialog boxes since it really isn't intuitive.  But adding it to the AvailableParts at runtime to avoid the second restart was problematic, to say the least

Sadly figured out I was simply misundestanding you AFTER hitting reply. Ugh.

Link to comment
Share on other sites

4 hours ago, linuxgurugamer said:

That will disable this mod.  This mod will NOT do anything to any part that has a ModuleCargoPart, if there is one, nothing is generated.

Could you make an option for generating output for all parts? (including the ones with the ModuleCargoPart) I want to see full output and compare volumes.

Edited by flart
Link to comment
Share on other sites

On 4/1/2021 at 3:00 AM, flart said:

Could you make an option for generating output for all parts? (including the ones with the ModuleCargoPart) I want to see full output and compare volumes.

I thought I had fixed that, it was supposed to do that.  I'll get that added soon

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...