Jump to content

The official unoffical "help a fellow plugin developer" thread


Recommended Posts

Nope. :/

Every time you want to make a change to a .dll file, you need to quit entirely and restart.

The best option is to make a second KSP install for dev purposes with a minimum of parts. Loading parts is 95% of the load time so if you can pare it down to only 10 parts, it loads much faster.

D.

Link to comment
Share on other sites

Nope. :/

Every time you want to make a change to a .dll file, you need to quit entirely and restart.

Thank you Diazo, that is a very helpful reply.

Given that I was going to do the mod for fun and that this situation is no fun at all, I'm not going to do a mod after all.

I might come back to it later, but seriously 35s (I measured) is way too long. To keep things fun I much prefer times under 1s.

My esteem for all the modders just went even higher! I hope that some day someone figures out a way to speed up the cycle.

Link to comment
Share on other sites

Hey, so I've modded some games a while back and I'm just curious how difficult it is to mod ksp before I attempt it. E.g., if I wanted to do something kinda simple, like change the launch button in the VAB to instead check if a condition with the ship is met (like it has a certain part or something), and instead give a popup or grey out if the condition isn't met, how difficult would this be? And if that's pretty easy, what kind of steps would I need to do to accomplish that?

Link to comment
Share on other sites

Covers most of the basics: http://wiki.kerbalspaceprogram.com/wiki/Plugins, and there are some great examples in TriggerAu's sig (see Plugin Framework)

EditorLogic.fetch.launchBtn

That will get you the button, there will be a state reference (enabled maybe) in there. Just run whatever check you need in Update and set it to be disabled.

Edited by Crzyrndm
Link to comment
Share on other sites

Ah okay, I just get super lost when I first start modding, after reading a bit I think I think I've figured out how to get that going. So I'd basically make a module that starts up in the VAB editor and on update check something to enable/disable the launch button or something to that effect? That doesn't sound too hard :D

Link to comment
Share on other sites

FlightGlobals.activeTarget is the current target, you'll have to do a IsVessel? check on it.

Looking at that method in the brower, it returns a Part? Not sure what that means for when you have a planet targeted.

Relative velocity is then straightforward math and the node numbers are probalby in the FlightGlobals.activeTarget.vessel.GetOrbit() object somewhere.

Hope that helps,

D.

Link to comment
Share on other sites

How do I get the distance to the active target, it's relative velocity and the ascending/descending node numbers for it's orbit?

For the Target you use the targetObject of the active vessel

For Distance you use the vectors of absolute position between the two objects

For velocity its a similar thing to the distance, just use the getVelocity funtions and diff the vectors

AscendingNode/Descending node you need to do the math yourself, but you can look at existing code in MechJeb, KER, KAC or one of the others that already do this

Heres the first bit of code for the vessel, its target and distance between em Warning - this is from my head, but should be pretty close



Vessel vessel1 = FlightGlobals.ActiveVessel

if (Vessel1.targetObject is Vessel){
Vessel vessel2 = vessel1.targetObject

Vector3D vessel1Pos = vessel1.orbit.getRelativePositionAtUT(FlightGlobals.GetPlanetariumTime()) + vessel1.orbit.referenceBody.position;
Vector3D vessel2Pos = vessel2.orbit.getRelativePositionAtUT(FlightGlobals.GetPlanetariumTime()) + vessel2.orbit.referenceBody.position;

Double distance = (vessel1Pos - vessel2Pos).magnitude;
}

Link to comment
Share on other sites

Hello

So I decided to edit Interstellar, to remove everything but the microwave power transmitter stuff... because that's all I want.

I delete all the other .cv that didn't have to do with them, and moved on to removing the lines in the .cv that didn't matter(like the reactor power lines, and wasteheat). I have of course run to in problems...

Error	1	'FNPlugin.MicrowavePowerReceiver.OnUpdate()': no suitable method found to override
Error 2 'FNPlugin.MicrowavePowerTransmitter.OnStart(PartModule.StartState)': no suitable method found to override
Error 3 'FNPlugin.MicrowavePowerTransmitter.OnUpdate()': no suitable method found to override
Error 4 'FNPlugin.MicrowavePowerReceiver.GetInfo()': no suitable method found to override
Error 5 'FNPlugin.MicrowavePowerTransmitter.OnFixedUpdate()': no suitable method found to override

What did I do wrong?

Link to comment
Share on other sites

From the MicrowavePowerReceiver source :


class MicrowavePowerReceiver : FNResourceSuppliableModule, IThermalSource {

This class inherits from the FNResourceSuppliableModule and implement IThermalSource. So if your removed those it won't compile...

You should have a look at the source before going on a delete rampage.

Link to comment
Share on other sites

For the Target you use the targetObject of the active vessel

For Distance you use the vectors of absolute position between the two objects

For velocity its a similar thing to the distance, just use the getVelocity funtions and diff the vectors

AscendingNode/Descending node you need to do the math yourself, but you can look at existing code in MechJeb, KER, KAC or one of the others that already do this

Heres the first bit of code for the vessel, its target and distance between em Warning - this is from my head, but should be pretty close



Vessel vessel1 = FlightGlobals.ActiveVessel

if (Vessel1.targetObject is Vessel){
Vessel vessel2 = vessel1.targetObject

Vector3D vessel1Pos = vessel1.orbit.getRelativePositionAtUT(FlightGlobals.GetPlanetariumTime()) + vessel1.orbit.referenceBody.position;
Vector3D vessel2Pos = vessel2.orbit.getRelativePositionAtUT(FlightGlobals.GetPlanetariumTime()) + vessel2.orbit.referenceBody.position;

Double distance = (vessel1Pos - vessel2Pos).magnitude;
}

Close ! I just had to use Planetarium.GetUniversalTime() instead of GetPlanetariumTime(). That works. Many thanks!

Here's what I'm doing with it: http://forum.kerbalspaceprogram.com/threads/106192-LEDJeb-A-Physical-*and*-Virtual-LED-Readout

Link to comment
Share on other sites

Okay, I think I figured out the questions I need help on. I'm still playing with the interstellar mod.

For some reason this "works"

            {
foreach (ModuleGenerator generator in generators)
{
if (generator.generatorIsActive)
{
double output = generator.efficiency;
double gpower = part.RequestResource("ElectricCharge", output * TimeWarp.fixedDeltaTime);
nuclear_power += gpower
}
}
}

but I don't know if it's just pulling the number from efficiency is the best idea but I haven't figured out how to pull the number from the rate.

The second problem I'm having with is; that it's not running through FractalUK's power manger(FNResourceManager or the ORS one) to make sure that it has all the ElectricCharge it needs before sending it.

The other thoughts I had was to; just remove both modules(this and ModuleDeployableSolarPanel) and just tell it to remove lets say up 1 million ElectricCharge if it all the power it needed was there. but I don't know how to do that.

Thanks again

Seeker

Link to comment
Share on other sites

Hi, I have i question about KSPEvents.

I have an event, which is only 'clickable' by a kerbal on EVA.

For example:

[KSPEvent(active = true, guiActiveUnfocused = true, guiName = "MyEvent", unfocusedRange = 20f, externalToEVAOnly = true)]

private void Event()

{

}

Now I need to get the kerbal who triggered the event because I would like to teleport the triggering kerbal to another position.

Does someone know how this could be done?

Greetings

Fanatorium

Link to comment
Share on other sites

Hi, I have i question about KSPEvents.

I have an event, which is only 'clickable' by a kerbal on EVA.

For example:

[KSPEvent(active = true, guiActiveUnfocused = true, guiName = "MyEvent", unfocusedRange = 20f, externalToEVAOnly = true)]

private void Event()

{

}

Now I need to get the kerbal who triggered the event because I would like to teleport the triggering kerbal to another position.

Does someone know how this could be done?

Greetings

Fanatorium

Errr, the Kerbal is on EVA so must be the currently active vessel...

Link to comment
Share on other sites

MissionRecoveryDialog isn't returning the reputation, science and funds earned during flight. I've tried using both onVesselRecoveryProcessing and onVesselRecovered but neither of those will give me a value other than 0. However, each function will give me a value for the current universal time so I don't quite understand what's going wrong. An explanation would be very appreciated, thanks.

public void Start()
{ GameEvents.onVesselRecoveryProcessing.Add(RecoveryProcessingCallback);
GameEvents.onVesselRecovered.Add(RecoveryProcessing);
}

void RecoveryProcessingCallback(ProtoVessel pv, MissionRecoveryDialog dlg, float recovery)
{
MissionRecoveryDialog dialog = new MissionRecoveryDialog();

float repEarned = dialog.reputationEarned; float sciEarned = dialog.scienceEarned;
double fundsEarned = dialog.fundsEarned;
Debug.Log("[Recovery Timer] Rep: " + repEarned);
Debug.Log("[Recovery Timer] Sci: " + sciEarned);
Debug.Log("[Recovery Timer] Funds: " + fundsEarned);

double currentUniversalTime = Planetarium.GetUniversalTime();
Debug.Log("[Recovery Timer] Time of recovery: " + currentUniversalTime);
}

void RecoveryProcessing(ProtoVessel pv)
{
MissionRecoveryDialog secondaryDialog = new MissionRecoveryDialog();


float repEarned = secondaryDialog.reputationEarned;
float sciEarned = secondaryDialog.scienceEarned;
double fundsEarned = secondaryDialog.fundsEarned;
Debug.Log("[Recovery Timer] Rep: " + repEarned);
Debug.Log("[Recovery Timer] Sci: " + sciEarned);
Debug.Log("[Recovery Timer] Funds: " + fundsEarned);

double currentUniversalTime = Planetarium.GetUniversalTime();
Debug.Log("[Recovery Timer] Time of recovery: " + currentUniversalTime);
}

Link to comment
Share on other sites

You create a new MissionRecoveryDialog each time, so of course the value are 0. The callback provides the dialog instance in its parameters.

Not tested but should work (I forgot what the recovery value is):


public void Start()
{
GameEvents.onVesselRecoveryProcessing.Add(RecoveryProcessingCallback);
}

void RecoveryProcessingCallback(ProtoVessel pv, MissionRecoveryDialog dlg, float recovery)
{
float repEarned = dlg.reputationEarned;
float sciEarned = dlg.scienceEarned;
double fundsEarned = dlg.fundsEarned;
Debug.Log("[Recovery Timer] Rep: " + repEarned);
Debug.Log("[Recovery Timer] Sci: " + sciEarned);
Debug.Log("[Recovery Timer] Funds: " + fundsEarned);

double currentUniversalTime = Planetarium.GetUniversalTime();
Debug.Log("[Recovery Timer] Time of recovery: " + currentUniversalTime);
}

Link to comment
Share on other sites

You create a new MissionRecoveryDialog each time, so of course the value are 0. The callback provides the dialog instance in its parameters.

Not tested but should work (I forgot what the recovery value is):


public void Start()
{
GameEvents.onVesselRecoveryProcessing.Add(RecoveryProcessingCallback);
}

void RecoveryProcessingCallback(ProtoVessel pv, MissionRecoveryDialog dlg, float recovery)
{
float repEarned = dlg.reputationEarned;
float sciEarned = dlg.scienceEarned;
double fundsEarned = dlg.fundsEarned;
Debug.Log("[Recovery Timer] Rep: " + repEarned);
Debug.Log("[Recovery Timer] Sci: " + sciEarned);
Debug.Log("[Recovery Timer] Funds: " + fundsEarned);

double currentUniversalTime = Planetarium.GetUniversalTime();
Debug.Log("[Recovery Timer] Time of recovery: " + currentUniversalTime);
}

God, I'm such an idiot. That was it, thank you very much.

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