Jump to content

The official unoffical "help a fellow plugin developer" thread


Recommended Posts

4 hours ago, linuxgurugamer said:

So right now, after using spawnEVA to send a kerbal out on EVA, I use an ejection force to get him away from the ship.  This has problems, mainly if the direction of the force happens to be into the ship, bad things happen (explosions, receding form Kerben at >40,000m/sec, etc).

I'd rather just have the kerbal let go, but haven't yet found how to do this.  Any ideas?

Thanks in advance

I believe spawnEVA does switch to the EVA kerbal as active vessel even if called when not active vessel. But could be wrong there.
As for how to get him/her to let go. KerbalEVA.OnALadder will be true if they are well, yep.
You can then KerbalEVA.fsm.RunEvent(kerbalEVA.On_ladderLetGo )

Link to comment
Share on other sites

4 hours ago, JPLRepo said:

I believe spawnEVA does switch to the EVA kerbal as active vessel even if called when not active vessel. But could be wrong there.
As for how to get him/her to let go. KerbalEVA.OnALadder will be true if they are well, yep.
You can then KerbalEVA.fsm.RunEvent(kerbalEVA.On_ladderLetGo )

Well, the OnALadder is not true right after the spawnEVA, but probably the next frame.

and, the ON_ladderLetGo is private, which means I'll have to do some Reflection to use it.  So next up is trying to capture the event onCrewOnEva 

Link to comment
Share on other sites

So I'm trying to turn on edge highlighting on a part when it's hovered over in a list (as shown in the screenshots) and I sort of have it working but not completely. When you hover over a part normally and it highlights green, it has very bright edge highlighting and can be seen through objects but if you look at what it looks like when I turn on the highlight with my plugin, it is like the old highlight method which is not as bright and not really visible through objects.

Here is the relevant code and some screenshots

if (hovercheck.Contains(Event.current.mousePosition))
{
	part.SetHighlightColor(Color.cyan);
	part.SetHighlight(true, false);
	part.highlightType = Part.HighlightType.AlwaysOn;
	part.gameObject.GetComponent<ExplosionDetector>().highlightPart = true;      
}
else if (part.gameObject.GetComponent<ExplosionDetector>().highlightPart == true)
{
	part.SetHighlightColor(Part.defaultHighlightPart);
	part.SetHighlight(false, false);
	part.highlightType = Part.HighlightType.OnMouseOver;
	part.gameObject.GetComponent<ExplosionDetector>().highlightPart = false;
}

Here is what it looks like when you hover over the part

DxHYjPW.png

Here is what my plugin looks like

N0uJwDC.png

Thanks :)

Link to comment
Share on other sites

I had a simple test window which was tagged with KSPAddon.Startup.EveryScene and used a random window id.
After updating to the current version the window still worked as expected except when going into either of the editors. In the editors the window gets created 3 times, but in all other scenes it just gets created once. 
Changing the attribute tag so use KSPAddon.Startup.AllGameScenes sorted the problem out. But I'm just curious as to why; KSPAddon still supports Startup.EveryScene but is it being phased out in favour of AllGameScenes ?

Also, I had a little helper class to jump me to a scene and load a craft as soon as KSP had loaded.  It also opened the debug console by setting;

HighLogic.fetch.showConsole = true;

But that doesn't do anything anymore (I guess due to the change to the console).  How do I open the new console in code?

Link to comment
Share on other sites

A question for all you smart people who understand  vector3

Here is the situation:

A ship, and a Kerbal has just exited and is holding on to the ladder (or, possibly, has let go and is floating there).  I want to use Vessel.AddForce(Vector3 awayFromCOM * ejectionForce)

where

awayFromCOM is calculated by pointing away from the Center of Mass of either the entire ship, or, preferably, from a specific part.  Right now I'm using : part.transform.up, (part is the kerbal), but, if the kerbal is underneath the ship, bad things happen.

How would I do this?

Thanks in advance.

Link to comment
Share on other sites

28 minutes ago, linuxgurugamer said:

A question for all you smart people who understand  vector3

Here is the situation:

A ship, and a Kerbal has just exited and is holding on to the ladder (or, possibly, has let go and is floating there).  I want to use Vessel.AddForce(Vector3 awayFromCOM * ejectionForce)

where

awayFromCOM is calculated by pointing away from the Center of Mass of either the entire ship, or, preferably, from a specific part.  Right now I'm using : part.transform.up, (part is the kerbal), but, if the kerbal is underneath the ship, bad things happen.

How would I do this?

Thanks in advance.

Gah, I feel stupid.

5 minutes after writing this, I found the answer:

Where:
origVessel is the ship
FlightGlobals.Vessels[i] is the Kerbal

Vector3 direction = FlightGlobals.Vessels[i].rootPart.transform.position - origVessel.rootPart.transform.position;
direction.Normalize();
FlightGlobals.Vessels[i].rootPart.AddForce(direction * ejectionForce);

I'm not sure yet of the order of the calculation, but it's mostly a matter of testing. 

Comments would be appreciated.

Edited by linuxgurugamer
Link to comment
Share on other sites

On 9/17/2016 at 10:38 AM, linuxgurugamer said:

Sorry, on mobile right now.  But that looks nice, what I'm working on will fit with it nicely, Eva parachutes and ejecting all kerbals.  Last problem is the ejection, and having them let go of the ladder

I may have a candidate event for you:          GameEvents.onPartLadderEnter.  Take a look at that and see if it can help... I've not expored it yet (working other bugs in other mods), but at least it gets you access into the proper point in time.

Link to comment
Share on other sites

44 minutes ago, Papa_Joe said:

I may have a candidate event for you:          GameEvents.onPartLadderEnter.  Take a look at that and see if it can help... I've not expored it yet (working other bugs in other mods), but at least it gets you access into the proper point in time.

What I need is something which is currently not available:  

KerbalEVA.On_ladderLetGo

But I've been told that something is going to be done soon in the game, so now I'm just waiting.

I will look at that, and the OnPartLadderExit, but I need to be able to let go of the ladder, which is a bit different.

Thanks

Link to comment
Share on other sites

1 minute ago, linuxgurugamer said:

What I need is something which is currently not available:  

KerbalEVA.On_ladderLetGo

But I've been told that something is going to be done soon in the game, so now I'm just waiting.

I will look at that, and the OnPartLadderExit, but I need to be able to let go of the ladder, which is a bit different.

Thanks

Sounds like a plan :wink: 

Link to comment
Share on other sites

I feel like banging my head against a wall.

I'm trying to trigger the event that tells a kerbal on a ladder to let go.

The only events related to the ladder are:

    public static EventData<KerbalEVA, Part> onPartLadderEnter;
    public static EventData<KerbalEVA, Part> onPartLadderExit;

Using the following:

if (kEVA.OnALadder && kEVA.Ready)
{
   KerbalEVA kEVA = FlightGlobals.ActiveVessel.GetComponentInChildren<KerbalEVA>();

I've tried:

EventData<KerbalEVA, Part> onLadderExit = new EventData<KerbalEVA, Part>("onLadderExit");
onLadderExit.Fire(kEVA, kEVA.LadderPart);

and

EventData<KerbalEVA, Part> onLadderExit = new EventData<KerbalEVA, Part>("onPartLadderExit");
onLadderExit.Fire(kEVA, kEVA.LadderPart);

and

GameEvents.onPartLadderExit.Fire(kEVA, kEVA.LadderPart);

After firing the event, I then tried waiting 5 ticks (in FixedUpdate).

Nothing happens.  the kerbal is on the ladder and stays there

So, what am I doing wrong here?

Link to comment
Share on other sites

1 hour ago, nightingale said:

 @linuxgurugamer - you've got it backwards, the event is fired on response to the Kerbal letting go out falling.

The actually check is in the KerbalFSM somewhere - I'm not sure if there's a simple way to trigger it yourself offhand.

Yes, I was sent on a wild goose chase by what someone (at Squad) said :-)

A solution has been implemented in the next version, so this particular discussion can be let go.

Link to comment
Share on other sites

17 minutes ago, linuxgurugamer said:

Yes, I was sent on a wild goose chase by what someone (at Squad) said :-)

A solution has been implemented in the next version, so this particular discussion can be let go.

Assuming the kerbal is on the ladder (to be sure you'll find the let go event), you can run the right event directly:

var fsm = FlightGlobals.ActiveVessel.gameObject.GetComponent<KerbalEVA>().fsm;
var letGoEvent = fsm.CurrentState.StateEvents.SingleOrDefault(e => e.name == "Ladder Let Go");

if (letGoEvent == null) 
    Debug.LogError("Did not find let go event");
else fsm.RunEvent(letGoEvent);

 

Link to comment
Share on other sites

44 minutes ago, xEvilReeperx said:

Assuming the kerbal is on the ladder (to be sure you'll find the let go event), you can run the right event directly:


var fsm = FlightGlobals.ActiveVessel.gameObject.GetComponent<KerbalEVA>().fsm;
var letGoEvent = fsm.CurrentState.StateEvents.SingleOrDefault(e => e.name == "Ladder Let Go");

if (letGoEvent == null) 
    Debug.LogError("Did not find let go event");
else fsm.RunEvent(letGoEvent);

 

Thank you. 

Link to comment
Share on other sites

How to deploy a chute?

I've added a KIS EVA item, a wearable parachute.

0bYqcld.png

And it works fine... on the ground.

The problem is the bounding box for registering right-click seems to lag behind the kerbal. While walking, that's not a problem, as it's at worst several centimeters off, upper half of the chute not registering clicks or so. But when falling 200m/s, the actual click may register if I'm clicking several meters above the falling kerbal. This is a kind of an issue.

How can I fix this? I guess the rightclick issue may be hard to solve, too ingrained into the engine,  but if the chute was to be activated by key (e.g. bound to a Brakes action group), or staged, or triggered through KIS Inventory action - that would work. But how do I do it? It can't be done in VAB, as the chute is usually stowed in some container, and only appears physically in the world once the kerbal equips it.

Actually that would be one more solution: that the parachute initially starts in the ACTIVE state, instead of STOWED - the kerbal wears an already armed parachute, and it deploys as soon as pressure and altitude are right, without taking any action.  (it's just an entry in KIS inventory before equipping, so it won't deploy before being equipped.)

But how do I do any of these things? Preferably just by .cfg file option, but if that's not possible, a plugin?

Edited by Sharpy
Link to comment
Share on other sites

40 minutes ago, Sharpy said:

How to deploy a chute?

I've added a KIS EVA item, a wearable parachute.

0bYqcld.png

And it works fine... on the ground.

The problem is the bounding box for registering right-click seems to lag behind the kerbal. While walking, that's not a problem, as it's at worst several centimeters off, upper half of the chute not registering clicks or so. But when falling 200m/s, the actual click may register if I'm clicking several meters above the falling kerbal. This is a kind of an issue.

How can I fix this? I guess the rightclick issue may be hard to solve, too ingrained into the engine,  but if the chute was to be activated by key (e.g. bound to a Brakes action group), or staged, or triggered through KIS Inventory action - that would work. But how do I do it? It can't be done in VAB, as the chute is usually stowed in some container, and only appears physically in the world once the kerbal equips it.

Actually that would be one more solution: that the parachute initially starts in the ACTIVE state, instead of STOWED - the kerbal wears an already armed parachute, and it deploys as soon as pressure and altitude are right, without taking any action.  (it's just an entry in KIS inventory before equipping, so it won't deploy before being equipped.)

But how do I do any of these things? Preferably just by .cfg file option, but if that's not possible, a plugin?

Hi , I'm not sure about the latest Pre versions but in 1.1.3 there was no way to get the chute toggle, and in fact connecting the chute via KIS turned out to be something that the game didn't like.  By now you've likely discovered that the chute will be operational if you can keep the gui open,  which is an issue if you just need an emergency bailout.  I seriously beat this thing till I was sick of it, spoke to everyone including Ferram and the Kis guys and in the end Squad. I got nowhere. As the chute was attached by a mod (KIS) that mod has an effect on the chute toggle, in previous versions you could see that the collider around the chute appears to be flickering on and off, and I reckon that is the root of the trouble. If you can't click the collider you cant activate the chute. Take a look in my  chute thread and it may stop you just repeating what i went through. and hopefully you ca get further with it than I.  Good luck

Spoiler

 

 

Link to comment
Share on other sites

1 minute ago, SpannerMonkey(smce) said:

Hi , I'm not sure about the latest Pre versions but in 1.1.3 there was no way to get the chute toggle, and in fact connecting the chute via KIS turned out to be something that the game didn't like.  By now you've likely discovered that the chute will be operational if you can keep the gui open,  which is an issue if you just need an emergency bailout.  I seriously beat this thing till I was sick of it, spoke to everyone including Ferram and the Kis guys and in the end Squad. I got nowhere.

Interestingly:   equipMode = physic makes the chute behave 100% nice rightclick-wise, but the kerbal movement gets all kinds of wonky (as if really drunk...)

Only in equipMode = part the clicking problem appears. 

Still, I wouldn't care for rightclicking. I believe the best way to do this - if there's no easier alternative - would be to call deployAction (action group action) from KIS OnItemUse. Adding a custom action to an item in KIS is quite easy. I have no clue about activating Action Group events though, if they were not defined in an action group, but on the fly (triggering custom, VAB defined action groups is done e.g. by SmartParts.)

 

Link to comment
Share on other sites

My question for you guys isn't technical programming this time, but general mod-keeping.  When do you guys release your 1.2-compatible versions?  If you put it out before 1.2 officially drops, how do you keep issues between it and someone playing 1.1.3 from happening?

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