Jump to content

How to check the status of action groups.


Recommended Posts

I'm working on writing a plugin, but I can't for the life of me figure out how I'd be able to check if any of the action groups are active. If it helps, I'm trying to write a for loop in FixedUpdate that will, ideally, run some stuff when my craft is at 50m off the terrain, and when the brake action group is on. I'd imagine it'd be something in KSPActionGroups.Brakes, but to paraphrase the priest from Firefly, "I ain't found excrements".

Link to comment
Share on other sites

KSPActionGroups is just the enumerator for... well... action groups. You want the ActionGroups property of the active vessel. Something like this should work for you

if (FlightGlobals.ActiveVessel.ActionGroups[KSPActionGroup.Brakes])
{
    // Things to do if the brakes are on go here
}

 

Link to comment
Share on other sites

Note that in stock, there is no relation between the state of the action group and the state of the actions in the group.

When you activate (or deactivate) an action group, KSP tells all actions in that group to turn on (or off), and that's it.

If the action can't do so, or if the action is in multiple action groups, you can get a situation where the action group is activated but the actions (or some of the actions) in the group are not.

This is what causes the first press of the Gear button to do nothing sometimes when a vessel is first launched.

It sounds like that will not be an issue for what you are right now, but if you get more involved later on (or for others finding the thread), it is something to be aware of.

D.

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