Jump to content

Several questions on part characteristics and references


Recommended Posts

I got the Part Select window plugin to a level of feature development such that with a bunch of polish to the sorting and UI it could be used with a stock game (or mods which don't use custom part modules). Essentially, that means the next big step has to be integrating support for a bunch of custom part modules.

Taking FAR as an example (because I accidentally ran into it earlier this week). It replaces the stock control surfaces with it's own custom module and thus I need to be able to check for that module as well. The sticking point is that I need to do this without creating a hard dependency on FAR and I don't know if a simple check to see if the plugin is loaded (I'm assuming this is simple since I'm not at my dev PC atm...) will be enough to prevent it breaking if it doesn't exist or if something far more drastic will be required.

Essentially, will I be able to get away with this:


if (loadedPlugins.Contains(FAR) && part.contains(FARControlSurface))
{
//Do things
}

My next difficulty stems from parts that have functionality that I can't seem to find any reference to in the Part itself (particularly ladders and wings). Is there a way to detect that a part can be latched onto by an EVA'd kerbal (Ladder) or that a part can provide lift (wing). Is there something beyond the Part definition that I haven't found yet?

Lastly, I intend to create a new part tooltip window that has a fixed position in the 'X' plane such that it doesn't follow the cursor into the window and obscure things like the stock one does. The major point I'm currently missing is the part image/camera to show what the part looks like. Any clues on how those are referenced?

Link to comment
Share on other sites

While I can't help you with your other questions, their is an easy way to get the partModules on a part.

Query the Part.Modules list, it is generated at loadtime (and so includes all ModuleManager config changes) by KSP and lists all partModules on that part.

So for the FARControlSurface example:


if(part.Modules.Contains("FARControlSurface"))
{
//Do things
}

I can't help you on your other questions, but this should get you going on this part.

D.

Link to comment
Share on other sites

Well that's news to me. For some reason it didn't even occur to me that modules could be referenced by name instead of type :rolleyes:. It atleast allows for basic categorisation, I'll just have to deal with the sorting issues later...

RE: Wings

I finally found out how to reference these little annoyances: Part.GetComponent("Winglet"). Now, to find the ladders...

Link to comment
Share on other sites

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...