Jump to content

The official unoffical "help a fellow plugin developer" thread


Recommended Posts

Is there a simple way to find the parent body of a given CelestialBody other than going through all the FlightGlobals.bodies and checking HasParent? I don't see anything relevant in the definition of the CelestialBody class, but maybe it's somewhere else?

Link to comment
Share on other sites

  On 9/22/2017 at 1:37 PM, Benjamin Kerman said:

I have a bit of code for that, already written, that should do the trick for finding a list of all CelestialBodies. 

https://github.com/BenjaminCronin/Ludicrous-Propulsion-Systems/blob/master/Plugin Dev/IIpD_PartModule.cs#L193-L201

@garwel

Expand  

There is already such a list in FlightGlobals.Bodies, but it's not what I was looking for. Anyway, DMagic's answer worked ok for me.

Link to comment
Share on other sites

Similar to mechjeb's Ascent Navball Guidance I'm trying to set a direction as my target  . Works fine (SAS can use it) but the target /Anti target markers won't show up and I don't get the "Target : Some vessel" UI message. What am I doing wrong?

 

	private DirectionTarget dirTgt = null;

	public  void newDirectionTarget(string name,Vector vec)
        {
            dirTgt = new DirectionTarget(name);
            updateDirection(vec);
        }

        private bool updateDirection(Vector vec)
        {
            if (dirTgt != null)
            {
                dirTgt.Update(new Vector3d(vec.X, vec.Y, vec.Z));
                return true;
            }
            else
                return false;
        }

FlightGlobals.ActiveVessel.targetObject = dirTgt;

 

Link to comment
Share on other sites

Hi all,

I need your assistance to fine-tune the RemoteTech's newly-modernised PID Controller as I have the limited understanding on the workings of this controller. The issue is in certain scenarios, it would take relatively long time to reach the target point. You can reproduce this observation by installing the develop-RT and save zips. The PIDTest vessel is good one to play with as it just takes long time to reach the target point like this picture below.

2Sg9iRX.png 

Any idea on how to shorten this time taken?

Link to comment
Share on other sites

  • 2 weeks later...

In my mod you take an asteroid sample if you are on EVA close to the target asteroid and your relative velocity is small. I just use the naive distance, which means that even if you touch the surface you are still some distance away (the asteroid radius basically).

I just visited the tiny asteroid, it is about 5 meter in radius. What is the largest size (max distance to CoM) asteroid you can encounter?

Link to comment
Share on other sites

  On 10/7/2017 at 10:44 PM, Rodhern said:

In my mod you take an asteroid sample if you are on EVA close to the target asteroid and your relative velocity is small. I just use the naive distance, which means that even if you touch the surface you are still some distance away (the asteroid radius basically).

I just visited the tiny asteroid, it is about 5 meter in radius. What is the largest size (max distance to CoM) asteroid you can encounter?

Expand  

You can probably get the information from the astroid type (A, B, C, D, or E) and use that to calculate the radius of the astroid. I can't comment about the actual distances, you might have to hyperedit to a couple of different types to see (with the plugin running reporting how far the kerb is from said astroid) how big they are. 

Link to comment
Share on other sites

You may find the mass ranges of asteroids of utility. Then you can find the density by comparing the mass and radius of a few asteroids and use that to estimate the radius by size class. Or just use the density you found earlier and the mass of the 'roid to find its approximate radius.

I'm pretty sure the lumps are all about the same height relative to the radius, so the measure should be reasonably accurate.

(ref: https://wiki.kerbalspaceprogram.com/wiki/Asteroid)

Edited by 0111narwhalz
Link to comment
Share on other sites

Hello guys,

 

I have been a couple of times trying to figure out where to start with plugin dev but every time I desist because I end up lost with the huge amount of information in this forum.

I have simple plugin in mind that shows a table of the parts of a ship in VAB in a simple window, like Kerbal Engineer Redux, for 1.2.2 in principle, but I am thinking on testing it also on 1.3 and 1.3.1.

so I have a couple of simple questions:

1) What Unity version 1.2.2 uses? I think it is 5.4.0p4 , but I am not 100% sure.

2) Do you know any simple example of a mod doing a windows in VAB that I could use to figure out how it works. I tried with KER and I got lost :-(

Thanks in advance.

 

Link to comment
Share on other sites

@mihe

  1.  Yep it's the right one.
  2. You can check Real Time Clock, in my sig, it display a clock in all scene (almost). Probably the most simple GUI that can be done :wink:. I have a little more complicated GUI in Antenna Helper if it can help.
Link to comment
Share on other sites

Any idea how to pull the current orbital parameters of a maneuver node/patch conic rendering.

This:

0d6iBD9.png

I thought ManeuverNode.solver.orbit.ApA etc would call it - but this seems to pull the ApA of the original node before it was edited, even after calling ManeuverNode.solver.UpdateFlightPlan() - when the node changes the new ApA doesn't get pulled through. I've also tried ManeuverNode.patch.ApA and ManeuverNode.solver.LastActivePatch.orbit.ApA

What I am basically trying to do is write a solver that will create a maneuver node to circularise an orbit. I know the solver code is wrong, but I can't see where it's going wrong because the figures are never being updated.

 

Edited by severedsolo
Link to comment
Share on other sites

  On 12/14/2016 at 3:59 AM, nightingale said:

@DMagic - looks like I inadvertently broke this will adding rounding in to fix another issue.  I tried to be clever and round using the display format, which doesn't work with the P0 display format (because Float.Parse() doesn't have smarts to recognize a percentage).

As a workaround, try using N1 + asPercentage.

Expand  

Can you confirm that this bug is still there?  I still can't do the percentage

Link to comment
Share on other sites

  On 10/15/2017 at 12:31 PM, linuxgurugamer said:

Can you confirm that this bug is still there?  I still can't do the percentage

Expand  

I can't really confirm since I'm no long with Squad. :)

But from what I recall I had put in a fix for that, which should've been released by now.  So if it's not working - raise it up as a bug.

Link to comment
Share on other sites

  On 10/14/2017 at 3:38 PM, Li0n said:

@mihe

  1.  Yep it's the right one.
  2. You can check Real Time Clock, in my sig, it display a clock in all scene (almost). Probably the most simple GUI that can be done :wink:. I have a little more complicated GUI in Antenna Helper if it can help.
Expand  

Thanj you Lion !! I am going to check it right now :-)

Link to comment
Share on other sites

  • 4 weeks later...

*Edit: Found the answers for the long question previously posted here on my own. Although the implementation can be further improved, it's done:

https://forum.kerbalspaceprogram.com/index.php?/topic/167548-*

Leaving the original question down here for reference:

  Reveal hidden contents

 

Edited by NotTheRealRMS
Already solved this
Link to comment
Share on other sites

Is there a GameEvent that is triggered when docking? I've added a button to the context menu for docking ports, but I only want that button to be shown on docking ports that are docked.
There is an event `onPartUndock` that I can use to hide the button after undocking, but I can't seem to find an equivalent event to trigger showing the button when docking. 
I can kinda get the desired end result using onVesselPartCountChanged and then checking this.part for ModuleDockingNode and seeing if that has otherNode, but a) that doesn't work on docking ports that are already docked when the scene is loaded and b) if I put a Debug.Log() into that process it shows it making numerous calls (possibly for every part, not sure) so that seems like the wrong way to be going about doing this.

What would be the right way of only showing something on a docking port's context menu when the port is docked?

Link to comment
Share on other sites

@katateochi build your own with an if statement looking at Vessel.Situations. 

https://kerbalspaceprogram.com/api/class_vessel.html#acea90b73d9b4523383503ec82f2f63bb

bool vesselDocked;
OnFixedUpdate()
{
	if(Vessel.Situations == 128)
	{
  		vesselDocked = true;
	}
}

(Note: i don’t know if the above code will work, but its my best guess. I have never worked with enums, I’m just relaying what I found. Official MS documentation here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/enum)

Link to comment
Share on other sites

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