Jump to content

Is there a way to disable a KSPAction?


Recommended Posts

I have a PartModule that has certain features available depending on how the user configures the part in the editor. I was wondering if there was a way to disable a KSPAction if the user doesn't enable a specific feature on the part. As it stands right now, I just have the KSPAction not do anything if the feature wasn't enabled, but I'd much rather hide it so that a user won't be confused on why the Action doesn't work.

Link to comment
Share on other sites

You need to find the BaseAction that the KSPAction generates in your PartModule.Actions list and set that BaseAction.active = false. I *think* the method name in the KSPAction will be the BaseAction.name field, but test that, it's from memory as I have not checked my code.

That will disable the action so it can not activate and it will not show in the KSP default action groups editor. Note that mods that deal with actions will still see it, but if those mods are setup correctly they will also hide any BaseActions that are .active = false;

For reference, when KSP loads a part module, it automatically uses the KSPAction property to generate the BaseActions it populates the PartModule.actions list.

Hope that helps,

D.

Edited by Diazo
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...