Jump to content

Getting all Engine Parts


Recommended Posts

Hi Guys,

I'm new to KSP modding and I will post a lot of noob questions in the next time. Is this the right place for that?

However, my main question is: How do I get all engines of a vehicle, so I can manipulate their individual thrust an so on? I know there is a method to get parts by category, but I don't know what arguments to enter. Or can I maybe search their config files for the ModuleEngines Module?

Simon

Link to comment
Share on other sites

This is indeed the right place. :)

If you want to get all engines for a vehicle, you'll want to search through all parts in the vessel's parts list, and check each one to see if it has an engine module (ModuleEngines, ModuleEnginesFX, or any other engine module).

Category won't help (the LES is in Utility, for example), and won't catch any parts that had a module added dynamically.

Link to comment
Share on other sites

For all engine PartModules:

var engineModules = vessel.Parts.SelectMany(p => p.Modules.OfType<ModuleEngines>());

For all parts which have engine PartModules:

var partsWithEngines = vessel.Parts.Where(p => p.Modules.OfType<ModuleEngines>().Any());

This is off the top of my head, so capitalization may vary.

Link to comment
Share on other sites

  • 2 years 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...