Jump to content

The official unoffical "help a fellow plugin developer" thread


Recommended Posts

I have a short question. Does increasing the power/thrust of an engine in the configuration files change the rate at which it consumes fuel?

No.

As far as I know, the only thing that changes the rate at which it consumes fuel is the specific impulse, which is vaguely analogous to "gas mileage." It is in the configuration files in the ModuleEngines section, atmosphere curve subsection. In the nuclear engine


MODULE
{
name = ModuleEngines
minThrust = 0
maxThrust = 60

atmosphereCurve
{
key = 0 800
key = 1 220
}
}

the first key says that at zero atmospheric pressure, the specific impulse is 800 seconds, and the second key says at full atmospheric pressure the specific impulse is 220 seconds.

Chemical rockets tend to max out specific impulse at about 450 seconds.

For various real world propulsion systems there seems to be an inverse relationship between thrust and specific impulse. Chemical engines have high thrust but low specific impulse. Ion engines are the reverse. There does not seem to be any propulsion systems with both high thrust and high specific impulse, except for outrageous extreme rockets like Orion nuclear pulse and Zubrin's infamous nuclear salt water rocket.

Link to comment
Share on other sites

I will have to admit that I am a complete noob. As such, I did not understand everything of your answer. But I'm thankful you responded regardless! If I may pester you a bit more with a slightly related question. I once changed one of the engines to use just ElectricCharge as resource. But upon trying to use that engine, the engine did not do anything at all. Mind, I was smart enough to give the vessel batteries connected to the engine, as well as solar panels.

I'll admit that I am trying to 'cheat'. I was hoping to increase how long fuel lasts, without increasing it's weight, or the amount of fuel pieces needed on a ship.

Link to comment
Share on other sites

I will have to admit that I am a complete noob. As such, I did not understand everything of your answer. But I'm thankful you responded regardless! If I may pester you a bit more with a slightly related question. I once changed one of the engines to use just ElectricCharge as resource. But upon trying to use that engine, the engine did not do anything at all. Mind, I was smart enough to give the vessel batteries connected to the engine, as well as solar panels.

I'll admit that I am trying to 'cheat'. I was hoping to increase how long fuel lasts, without increasing it's weight, or the amount of fuel pieces needed on a ship.

To do that make the Atmosphere Curve have something like


atmosphereCurve
{
key = 0 5000
}

or an even higher number.

Just keep in mind that you'll have a rocket engine that only exists in fantasy.

I'm not sure why your ElectricCharge hack did not work. But you really do not need it if all you want to do is cut down on fuel consumption.

Link to comment
Share on other sites

Thanks once more for your reply :) What exactly does athmosphereCurve do, or mean? Is it something like air resistance? You mentioned gas mileage? As for my electriccharge hack. Despite batteries, radial ones and packs, being attached directly to the engine, it did not receive any electrichcharge resources, as though it was not connected. Presumably electriccharge behaves differently from liquidfuel and oxidizer. Or perhaps it is because electriccharge has no density? To be honest, I have no idea!

Link to comment
Share on other sites

This is technically the plugin development thread so config file questions are rather off topic (at least, those not concerning plugins). General or add-on development would be a better place.

But to answer the question.

ModuleEngines specifies fuel consumption in ISP. This is essentially mass flow per unit of thrust.

So as fuel consumption is specified as this the litres of fuel consumed per second depend on the mass of the fuel and the thrust of the engine. Increasing engine thrust does increase fuel consumption, and trying to run on a fuel without any mass (e.g. electricity) doesn't work because the module in question doesn't know how to calculate fuel use for a massless fuel.

atmosphereCurve specified the ISP values for the engine at different atmosphere densities (or possibly pressures, the difference isn't big). If you want an engine that goes further then you need to increase the second column of values.

Link to comment
Share on other sites

The stuff in the debug window gets printed out to %KSPFolder%\KSP.log as well, so in the event you can't work out how to keep the log window and your window open at the same time, there's always the option of checking the log file.

The PDebug class has a bunch of static methods which print to the log.

Where did you find the info about this class? Where can I find all the documentation that I'm missing on all of the classes?

It's a bit frustrating, working in the dark. :)

Link to comment
Share on other sites

Where did you find the info about this class? Where can I find all the documentation that I'm missing on all of the classes?

It's a bit frustrating, working in the dark. :)

In Visual Studio you can view the classes and their methods with Object Browser.

3ITDm.png

Simply searching "Log" outputs the desired methods:

3ITG6.png

Link to comment
Share on other sites

Some comprehensive modding tutorial would be nice. Anyways, i got far enough to do some simple stuff within KSP, but got quite some "why the f doesn't that piece of s do what i told it" moments. Is there any way to debug my mod with something that at least barely resembles an IDE? I have some experiences in modding for a pure .NET game, where Visual Studio allowed that pretty easy, even with the free VS, showing just my stuff on the stack and all calls to the game as "external code". But i could not find any way for KSP. Looks like its only possible for e.g. MonoDevelop to attach to the game when using Unity Editor or a development build of the game. On the other hand does for example the romfarer.dll has set some interesting debugging settings. So has anyone found a good way to debug our own mods?

Link to comment
Share on other sites

Yes I would have thought that a game designed for the user to build upon would have had better documentation of its classes. Just my opinion.

But it spawned an interest of Unity for me and I haven't played KSP much. I'm learning Unity first so I can make stuff work in Unity.

Link to comment
Share on other sites

In Visual Studio you can view the classes and their methods with Object Browser.

And this is then exported to XML by whoever maintains the github repo for the XML documentation, right?

On a slightly similar vein, does this kind of thing exist in Xamarin Studio (aka MonoDevelop)? I've noticed that the code completer is EXCELLENT at parsing the available libraries (much better than CodeBlocks that I use at work), but does an Object Browser exist? I bet I've missed it in some really obvious place :D

Link to comment
Share on other sites

Is it possible to add GUI elements without adding parts? I want to add some basic info panels to the game, such as the current and target apsis info. Is there a way to do this without adding a part?

Link to comment
Share on other sites

Is it possible to add GUI elements without adding parts? I want to add some basic info panels to the game, such as the current and target apsis info. Is there a way to do this without adding a part?

Yes, it is possible and it is not hard. Take a look at http://forum.kerbalspaceprogram.com/showthread.php/37664-A-GUI-framework-for-modders, and my Fuel Balancer mod (http://forum.kerbalspaceprogram.com/showthread.php/25823). I haven't had a chance yet to work with evilC on his example framework, but he used my TacLib classes to create a simple example.

Link to comment
Share on other sites

Hi,

I'm trying to get some custom internal props using a new internal module. I want it to display text much the same as the internal speedometer works. I think it's using InternalText, but it's really all a mystery to me. Can anyone point me in the right direction?

Link to comment
Share on other sites

Hello everyone,

Is there a way to get the surface height of a planet at given coordinates (lat, lon)?

In 0.20 using PQS.GetSurfaceHeight(<surface vector>) - PQS.radius returned correct results but that isn't the case anymore. Have there been changes to the API I didn't notice and is there still a way to get this information?

Link to comment
Share on other sites

Guest bfishman

Hello everyone,

After extensive searching through existing mods (mostly Romfarer's Lazor Docking Cam), I'm still having difficulty with determining the "active" docking port / command pod (i.e. "Control From Here").

Initially, I assumed that FlightGlobals.ActiveVessel.ReferenceTransform would provide the transform for the active control point, but it doesn't seem to be the case. Any suggestions?

Thanks for the help,

bfishman

Link to comment
Share on other sites

Anyone know how to get a parts list of an unloaded ship? Whenever I attempt to do it I get a list of size 0. I guess this is one of the optimizations of KSP... problem is I want to see which ships in the game have a certain part (even if they are somewhere very far away in the kerbal system).

Link to comment
Share on other sites

I am trying to make new part modules using Visual studio express 2012. but i cant even decipher where to even begin...

i have looked around the wiki but it was little help.

What am i missing? can anyone refer me to any tutorials? Can anyone provide a Template file to use?

I will greatly appreciate ANY help. thanks

Link to comment
Share on other sites

I am looking for some direction and advice. I want to make a simple module that will basically combine ModuleAnimateGeneric with ModuleGenerator.

I have worked through the wiki with the examples and read over the API that's available but I'm still not sure where to start.

Any help is appreciated :)

Thank you in advance

Link to comment
Share on other sites

Hello everyone,

After extensive searching through existing mods (mostly Romfarer's Lazor Docking Cam), I'm still having difficulty with determining the "active" docking port / command pod (i.e. "Control From Here").

Initially, I assumed that FlightGlobals.ActiveVessel.ReferenceTransform would provide the transform for the active control point, but it doesn't seem to be the case. Any suggestions?

Thanks for the help,

bfishman

Try Vessel.GetReferenceTransformPart()

I am trying to make new part modules using Visual studio express 2012. but i cant even decipher where to even begin...

i have looked around the wiki but it was little help.

What am i missing? can anyone refer me to any tutorials? Can anyone provide a Template file to use?

I will greatly appreciate ANY help. thanks

http://wiki.kerbalspaceprogram.com/wiki/Setting_up_Visual_Studio

Basically the set up is (the wiki page neglects to mention changing the framework version):

Create a C# Class Library project. Set to use the .Net 3.5 Framework. Add references to $(KSPFolder)\KSP_Data\Managed\UnityEngine.dll and $(KSPFolder)\KSP_Data\Managed\Assembly-CSharp.dll.

I am looking for some direction and advice. I want to make a simple module that will basically combine ModuleAnimateGeneric with ModuleGenerator.

I have worked through the wiki with the examples and read over the API that's available but I'm still not sure where to start.

Any help is appreciated :)

Thank you in advance

What exactly do you want to achieve? Saying you want to combine the two can be taken in a number of different ways.

Edited by Echo 8 ÉRÀ
Link to comment
Share on other sites

http://wiki.kerbalspaceprogram.com/wiki/Setting_up_Visual_Studio

Basically the set up is (the wiki page neglects to mention changing the framework version):

Create a C# Class Library project. Set to use the .Net 3.5 Framework. Add references to $(KSPFolder)\KSP_Data\Managed\UnityEngine.dll and $(KSPFolder)\KSP_Data\Managed\Assembly-CSharp.dll.

Thanks for your help, appreciate it, but I already looked at that, and http://wiki.kerbalspaceprogram.com/wiki/Creating_your_first_module

and i did everything it told me and it worked

but the problem is, (EDIT: Sorry i wasn't specific last time) that just shows you how to make a module that just enters into the log.

I don't know how to give it any other functions as i don't know what scripts the other functions use.

so say i wanted to give the XL solar array a different or extra function. so i try to write a new module for it to use, but i can't simply copy and edit the current module, or do i know every function it does. so i am trying to write in functions without knowing what each function should look like or what functions the original even had.

is there any way to make a copy of a current module, rename it and add or change it's contents?

Or even simply view the exact script a module contains?

Please Please Please. i need this plugin to make my mod word. do you (Echo 8 ÉRÀ) or anyone else have any way around this? or any other advice for me?

Edited by tomwillp
Link to comment
Share on other sites

Thanks for your help, appreciate it, but I already looked at that, and http://wiki.kerbalspaceprogram.com/wiki/Creating_your_first_module

and i did everything it told me and it worked

but the problem is, (EDIT: Sorry i wasn't specific last time) that just shows you how to make a module that just enters into the log.

I don't know how to give it any other functions as i don't know what scripts the other functions use.

so say i wanted to give the XL solar array a different or extra function. so i try to write a new module for it to use, but i can't simply copy and edit the current module, or do i know every function it does. so i am trying to write in functions without knowing what each function should look like or what functions the original even had.

is there any way to make a copy of a current module, rename it and add or change it's contents?

Or even simply view the exact script a module contains?

Please Please Please. i need this plugin to make my mod word. do you (Echo 8 ÉRÀ) or anyone else have any way around this? or any other advice for me?

The first hurdle in any project is knowing what you want to do. Until you can work that out, Hello World! examples are really the best thing we can advise you to follow.

For example, my very first plugin was an animation partmodule. Sure, it was terrible, but I didn't care. I wanted a cargo bay on my shuttle, there wasn't any mods out there with a cargo bay for my shuttle, so come Hell or high water, I'm going to make a cargo bay for my shuttle. And thus, [Plugin][Part][0.16] Animated Cargo Bay was born.

If you want to know what functions a plugin can use, open up the Object Browser. Basically anything that is public or protected is free for plugin makers to make use of.

Edited by Echo 8 ÉRÀ
Link to comment
Share on other sites

Try Vessel.GetReferenceTransformPart()

What exactly do you want to achieve? Saying you want to combine the two can be taken in a number of different ways.

Thank you for replying Echo 8 ÉRÀ.

I want to make a simple generator that when activated has an animation for starting up and vice-versa when deactivating.

I tried adding the ModuleAnimateGeneric and ModuleGenerator in the part config but that just gave two options on the part, one to toggle the animation and one to toggle the generator. I just want the one menu option to do both. Going through the forums I saw other people wanted the same thing. So figured I would try to make a module that would combine the ModuleAnimateGeneric and ModuleGenerator functions that are activated with a single activate option in game.

Link to comment
Share on other sites

Thank you for replying Echo 8 ÉRÀ.

I want to make a simple generator that when activated has an animation for starting up and vice-versa when deactivating.

I tried adding the ModuleAnimateGeneric and ModuleGenerator in the part config but that just gave two options on the part, one to toggle the animation and one to toggle the generator. I just want the one menu option to do both. Going through the forums I saw other people wanted the same thing. So figured I would try to make a module that would combine the ModuleAnimateGeneric and ModuleGenerator functions that are activated with a single activate option in game.

In that case, I personally would just tell people to just live with it. However, if I really wanted to do that I would:

  1. Make a list of all the fields I would need to read from a part.cfg to configure my partmodule
  2. At runtime, dynamically add the ModuleAnimateGeneric and ModuleGenerator partmodules to every part (via looping through PartLoader.LoadedPartsList[].partPrefab.Modules) which has added my new partmodule, while making sure I don't add duplicates
  3. Go through all the actions on the newly added partmodules and prevent them from showing up in the GUI. I think setting BaseAction.active = false should do the trick, not sure though
  4. Added a new KSPAction which does nothing but re-enable the disabled Toggle actions, fire them, then disable again
  5. Repeat the previous step for every other group of actions (Enable and Disable).

There's probably more to it, but that's your job to find out, since this is your project and not mine.

Link to comment
Share on other sites

I need help on multiple engine fx on 1 fuel tank.

I made an horizontal fuel tank with 4 integrated liquid engine. The 4 engine work properly but only 1 fx work. The 3 others wont appear. I tried to copy and paste the fx 3 times to get 4 full sets of fx but it seem to not working that way. How i can set my fx for each engine in 1 part.cfg ?

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