Jump to content

Determine a part type?


Recommended Posts

If I made a custom part and wrote a custom module for it, how would I determine if the part attached to my custom part, is of a certain type; like engine, wing, torque wheel, etc.

better yet, how would I do the above for all parts on a vessel, not just the attached one. Edited by Xyphos
Link to comment
Share on other sites

[quote name='JPLRepo']By defining it in the part config file and adding the appropriate partmodules for your part.
[URL]http://wiki.kerbalspaceprogram.com/wiki/CFG_File_Documentation[/URL][/QUOTE]

that's not what I asked. here's a picture.

[img]http://i.imgur.com/7Kd4F0y.png[/img]
Link to comment
Share on other sites

attached parts are part.parent and/or part.children if I remember correctly. Also, you don't really identify a part, you identify it's modules. Engines for example all have a module that is or extends from ModuleEngines (this includes just about every mod engine as well):
[code]part.Modules.GetModules<ModuleEngines>().count > 0[/code]

Doing it for the entire vessel just requires doing a recursive search of each parts parent and children if you care about the number of parts between the part with the module and the part you're checking, or iterating over vessel.parts if you dont Edited by Crzyrndm
Link to comment
Share on other sites

[quote name='Xyphos']that's not what I asked. here's a picture.

[URL]http://i.imgur.com/7Kd4F0y.png[/URL][/QUOTE]

Ok. I see. You would need to traverse the parts in your vessel there is a field that has the id of what it's attached to and then you can get the part type. Is this in the VAB or flight? I'm not near my computer now so I can't look it up for you.

EDIT:
Still not near computer but did a forum search.
Look at this thread. Talks about surface attached but you can do the same for attachnode attachments.
[url]http://forum.kerbalspaceprogram.com/threads/112204-SOLVED-surface-Attached-Parts?p=1768059&viewfull=1#post1768059[/url] Edited by JPLRepo
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...