Jump to content

Can I find out if an action group has actions in flight


Recommended Posts

I know about ActionGroupList, but all that exposes is API for toggling / setting / querying action groups.  What I'd like to do (while in flight) is find out if there is anything attached to an action group.  I don't care about the contents, all I want to answer is "Is there at least one action in this action group?".  I haven't had much luck with that, and it looks like trying to dig through a vessel ConfigNode file is going to be a serious mess, since the actions are attached to the parts.  Does anyone know of a simpler way to make that query?

Link to comment
Share on other sites

Assuming that you are working with a Vessel (such as FlightGlobals.ActiveVessel), you have to cycle every part and check the Part.Actions enum, then cycle every PartModule.Actions on that part to see what you are looking for.

If you don't care about which actiongroup and are just checking if one is assigned,  you can do a != KSPactionGroup.None check, but otherwise you have to do bitwise math.

Note that I've never seen an action assigned in the Part.Actions enum and assume it is old code replaced by the PartModule.Actions enum, but I still check it to be safe.

I make a list of all actions on a vessel here: https://github.com/SirDiazo/AGExt/blob/master/AGExt/Editor.cs#L3135

Then I check that list against a specific action type (Brakes/Lights/etc.) here: https://github.com/SirDiazo/AGExt/blob/master/AGExt/Editor.cs#L3170

Hope that helps,

D.

 

 

 

Link to comment
Share on other sites

13 hours ago, Diazo said:

Hope that helps,

Yeah, that helps.  Thanks for pointing out where that stuff resides in flight.  I was hoping I wouldn't need to iterate over all of everything for that info, but I have to do that anyway for other things, anyway, so oh well.

As long as the action groups aren't changed in flight *ahem* :) I can get away with my current 'onVesselChange' and 'onVesselWasModified' based update strategy.

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