Jump to content

How to make complex parts.


Recommended Posts

Hi guys. I want to make some parts, that will have properties from different part types. For example, wing, which can make lift and have fuel. Can somebody tell me, what code it should be?

Looked into that too, but as far as I know, you can only choose one. Think you need to make a new class with a plugin or something along those lines.

Link to comment
Share on other sites

Unfortunately, the PartModule system isn\'t used by the stock parts. There are some PartModule classes in the stock code base, but I believe they are just the examples from Mu\'s thread.

If you want a single part to handle multiple functions, you need to code in those handler functions yourself into a Part/PartModule subclass. Ideally, after the PartModule system moves beyond it\'s initial demonstration phase, you\'ll be able to include functionality by just adding blocks to the part cfg file, or even just drag and drop in the VAB, but it\'s just not there yet.

Right now, you either have to code a set of PartModules to handle the mechanics you\'re wanting to implement, and then add them to your cfg; or make a normal Part subclass that handles all of the mechanics, perhaps a set of functions/subroutines/methods that get called in sequence inside the (Fixed)Update block.

Happy moddings.

Link to comment
Share on other sites

  • 3 weeks later...

Unfortunately, the PartModule system isn\'t used by the stock parts. There are some PartModule classes in the stock code base, but I believe they are just the examples from Mu\'s thread.

Yeah, but we are going to gradually move all our part code into the new Module system, eventually deprecating the old part class extensions.

The latest parts already use this new system. Namely, the telescopic ladders and the launch clamps, and more should follow soon. :)

Cheers

Link to comment
Share on other sites

Sorry I\'m using this thread to ask, but will Mu or anyone else post PartModule examples that we can use for our own parts when the system is completely ready?

The PartModule system is working very well so far. It is brilliant, i can add modules to any part in the game and change their behaviour somewhat. Its easy to do this in the .cfg file but also possible to add, use and remove modules with code only. :) In my plugin im adding a module to all the kerbals on eva making them remember what vessel they belong to.

Link to comment
Share on other sites

BTW, if I\'m using part modules, is there a way to find out if I\'m in an assembly building or on flight scene and if the game is paused?

Everything I tried out was either wrong or not completely accurate.

Link to comment
Share on other sites

The easiest way to check in which scene you are in is to ask the HighLogic class. It holds all such information.

for instance:

HighLogic.LoadedScene - returns a GameScenes enum value for the scene you are in.

HighLogic.LoadedSceneIsEditor : bool (true in the VAB and SPH scenes)

HighLogic.LoadedSceneIsFlight : bool (true in the flight scene)

HighLogic.LoadedSceneHasPlanetarium : bool (true in the flight scene and tracking station)

Using those, you can set up a switch block or conditionals to do things based on the state of the game. It\'s much simpler than having to set up overrides for 30+ different callbacks.

Cheers

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