Jump to content

PowerShell Procedural Mechanic Training


Recommended Posts

So i was a little unsatisfied that i couldn't pick up and attach some of the science instruments, RCS blocks, and other small parts provided by various mods, and a related MOD that attempted to retrofit KAS modules onto other mods got me thinking about ways to generate KAS modules. couple of evenings of knocking about in powershell and i got this:

PowerShell Procedural Mechanic Training

this script searches the current directory for .Cfg files and procedurally generates module Manager Configs to enable KAS for small Parts.

Potentially asked questions:

OH GOD! WHY DOESN'T THIS WORK ANYMORE?

​
The specific module this script creates, KASModuleGrab, was deprecated from KAS in version 5, as part of the move to KIS, the Kerbal Inventory System. there doesn't seem to be a direct analog in the KIS modules, and i'm trying to understand the new modules and looking at exactly how to rework this functionality. more to come.

Wait; what does this thing do?

​
it search the current folder looking for parts that aren't enabled for KAS, and then creates a ModuleManager patch to enable them.

I'm a player, how do i use this?

The easiest way would be to drop it into your GameData folder, open powershell, Change directory to your GameData folder, set the script execution policy to enable unsigned scripts, and run it.


PS C:\Users\Sarah> cd 'C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\GameData'

PS C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\GameData> Set-ExecutionPolicy Unrestricted -scope Process



Execution Policy Change

The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose

you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution

policy?

[Y] Yes [N] No
[S]
Suspend [?] Help (default is "Y"): y

PS C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\GameData> .\ProceduralMechanicTraning.cfg

Command line options?

That's not really a question, but here are the supported switches:

[-Verbose]
Show a lot more about what is being done. mostly useless.

[-OutputFile <Filespec>]
Specify a different file name to write. mainly for mod makers who want to use this to quickly generate configs for their parts, or people who really care about organization of their MM patches.

WHAT!?! allow unsigned scripts?!? you'd have me be VULNERABLE!? why are you so LAZY!

I am exactly as anonymous as I wish to be right now; I'm not about to go getting certificates and signing things, then publishing those things on the internet. Leave a girl a little privacy? use "-scope process" like in the example, then close that PowerShell process. everything's perfectly all right now. We're fine. We're all fine here now, thank you. How are you?

This thing made <Giant Part> grabbable. that's so unrealistic.

ya, i'm using part mass as a proxy for stored size. some of the aerospace parts are super light for their size. Balsa wood and canvas, who knew?

don't like this anymore. how do undo?

Delete the config file that was created. if you didn't specify a specific file name, then it would be ProceduralMechanicTraning.cfg in the root of your GameData folder.

I'm a mod maker, and i don't want my parts grabable.

don't make a KAS module for it. This script is for players who like and use your mod, but disagree about KAS grabability.

I'm a mod maker, and my mod is already grabbable. don't mess up my stuff.

I've tried very hard to ignore parts that already have KAS modules, but i might have messed something up. if you find an instance of this script replacing a KAS module, or making something game-breaking grabable (i.e. default struts) let me know and i'll add it to the list of static exceptions, or find a better way to exclude it.

I'm a mod maker, and i want to use this to generate my KAS modules

that's fine. just run this script on your mod's main folder, and let it walk through your mod, and then distribute the resulting config file with the license block intact. you might want to edit the resulting files because this script isn't very smart, and it might make 40 giant parts storable in a small KAS box.

OK, why write it in PowerShell? I'm on Mac stroke Linux stroke Windows 95 left paren delete as appropriate right paren.

Sorry, i did this in about three hours over a weekend, and i write fastest in PowerShell. it's released under CC BY-NC-SA 4.0, so feel free to port.

Pretties:

Javascript is disabled. View full album

Version History

  • 0.1.0.137.0: Initial release.
  • 0.1.1.141.0: Added state checking.

ToDo:

  • Better sizes: current version uses part mass as a proxy for size. Find a way to read .MU files and get basic dimensions and multiply by part's rescale factor to compute size.
  • Better procedural decisions for KASModuleGrab. current version uses lots of static values. figure out what each property of the KASModuleGrab does and make per part procedural decisions. looked through http://github.com/KospY/KAS/wiki/KASModuleGrab. none of these options are really required, or are useful for generic parts. i added a check for stateless.

DOWNLOAD:

DROPBOX:

License:

This file, and any derivatives, are released under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)

License details are available at http://creativecommons.org/licenses/by-nc-sa/4.0/

Edited by AetherGoddess
More questions? More Answers!
Link to comment
Share on other sites

  • 4 weeks later...
  • 2 months later...
  • 1 month later...
  • 3 months later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

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.

×
×
  • Create New...