Jump to content

How to tell when a docking field is engaged? [Answered]


Recommended Posts

How do I programmatically examine a docking port and answer the question "is the docking field engaged"?  (i.e. "has it latched on to something, but not yet actually docked")

I would have thought there'd be a boolean field (or similar) on ModuleDockingNode, but I've looked over that class and haven't been able to spot any likely-looking candidates.

 

On a somewhat related note:  When two ships are docked, and you undock them, the docking ports deliberately are inactive (no docking field) until the docking ports are separated by at least a certain minimum threshold distance.  At that point, the ports "reset" and become dockable again.  Would also be interested in knowing how to detect that state or transition.  In other words:  how to distinguish "field is ready, but not engaged because they're not close enough" versus "field is temporarily disabled because they just undocked and haven't reached the reset point yet".

Link to comment
Share on other sites

You should be able to look at ModuleDockingNode.state.  This is a string of the name of the current state of the docking state machine.  I think the state should be "Acquire" or "Acquire (dockee)" when it is actively pulling in.  Not sure what it will be after undocking but before port reset but it should be easy enough for you to log it and find out...

Link to comment
Share on other sites

When the module is within the acquisition range and is the dominant port the state will be "Acquire". But the other port (not necessarily on the other vessel) will be "Docked (dockee)", even though it hasn't docked yet; the inactive port also won't have its magnets engaged. The active port switches to "Docked (docker)" once you dock.

When you undock, and haven't passed the reengage distance, it will be "Disengage", I think.

When the docking port isn't doing anything it will be "Ready"; if it's a shielded port I thing it might be "Disabled".

 

Link to comment
Share on other sites

Excellent, thanks guys!  Just what I was looking for.  :)

2 hours ago, DMagic said:

When the module is within the acquisition range and is the dominant port the state will be "Acquire". But the other port (not necessarily on the other vessel) will be "Docked (dockee)", even though it hasn't docked yet

So, if I'm understanding correctly:

  • When a docking is happening, it's an asymmetric process in the code.
  • One port is the docker, the other is the dockee.
  • The "status" string field is what I should look at.
  • "Docking field engaged" is indicated on the docker by a value of "Acquire"
  • However, the status for the dockee will say "Docked"

Is that correct?

If that's the case, then it sounds like it's easy for me to detect when a port is in the state "I am the docker, and the field is engaged but I'm not yet docked."

But how can I detect that state for the dockee?  That is, how do I detect the state "I am the dockee, and someone has engaged a docking field on me but is not yet docked"?  i.e. how to distinguish that from simply being docked?

Link to comment
Share on other sites

Both docking ports keep a reference to the matching node; otherNode. You can watch the status of both docking ports to decide when they are engaged and when they are actually docked.

Link to comment
Share on other sites

Ah!  Perfect.  Thank you, I should be able to get everything I need from that, and the asymmetry wart just needs a few extra lines of code to work around.

Thanks for the answers!

Link to comment
Share on other sites

Just as a follow-up:  I just now did a bit of experimentation to verify the various possible state strings.  Here's what I found:

  • When nothing's attached, the port says "Ready".
  • When something's attached, but from the vehicle editor and not from docking, then it's "PreAttached".
  • When the docking field is engaged, but not yet docked:  it's either "Acquire (dockee)" or "Acquire" (the docker doesn't have the suffix, for some reason)
  • When they're actually docked, it's "Docked (dockee)" or "Docked (docker)"
  • When they've undocked but haven't gotten far enough to reset yet, it's "Disengage" for both docker and dockee

So, it looks as though I never have to look at the otherNode to get the relevant status.  I can just use the string, and starts-with-"Acquire" or starts-with-"Disengage" as appropriate.

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