Jump to content

The official unoffical "help a fellow plugin developer" thread


Recommended Posts

Does anyone know if there's a way to create a custom slider tweakable like the engines have for throttle limiting? So far, the only tweakables i've seen in mods are buttons that execute functions.

Yes, like this: https://github.com/taraniselsu/TacSelfDestruct/blob/master/Source/TacSelfDestruct.cs#L38

Look at the UI_* attributes.

Link to comment
Share on other sites

Hmm... very sneaky! :P

Between RealChutes and TAC I now have some good examples for UI_Toggle and UI_Floatrange, but in my autocomplete list I see there are some others. Any idea if UI_Label, and UI_Vector2 are designed to be used similarly? They don't seem to show up in game for me, but I could certainly be missing something.

Link to comment
Share on other sites

Hmm... very sneaky! :P

Between RealChutes and TAC I now have some good examples for UI_Toggle and UI_Floatrange, but in my autocomplete list I see there are some others. Any idea if UI_Label, and UI_Vector2 are designed to be used similarly? They don't seem to show up in game for me, but I could certainly be missing something.

I believe UI_Label doesn't do much in this situation. As for UI_Vector2, I've tried to use it, but it doesn'T seem to be operational with tweakables unfortunately. I think only UI_FloatRange and UI_Toggle currently work.

Link to comment
Share on other sites

Has anyone figured out a way to add items to the list of science received after a vessel is recovered ? Would it be possible to trigger that to pop up even if the vessel was destroyed (with an added science entry) ? I'm trying to set up a plugin that will give science when something blows up in view of KSC, in view of a crewed vessel / EVA, or "lands" (destructively or as debris) on Kerbin (small amounts, with diminishing returns per part type, but enough to "learn from your mistakes" and be useful in the earlier stages of career). I think I can just add to the science directly by adding to ResearchAndDevelopment.Instance.Science, but I'd rather have it be listed like normal science data gathering after a mission is completed.

Link to comment
Share on other sites

I've gotten part way there I think, science is increased but it doesn't show on the recovery screen as an individual entry (just in the total science at the bottom).


ScienceSubject subj = new ScienceSubject("recovery@KerbinFlew", "Failure Analysis of flight components", 1.0f, (float)newScience, 10);

ResearchAndDevelopment.Instance.SubmitScienceData((float)newScience,subj);

Link to comment
Share on other sites

After looking at KSP's code with ILSpy (which can get some variable names, others it fails and instead of giving a nice human readable name outputs numbers but not as text.. i.e. the text view interprets them with symbols like [sOH] and [bS] and so forth), I may have a clue what I have to do. It looks like if instead of doing SubmitScienceData myself, I get my science into ScienceData and slap it as a certain kind of config node on a vessel that is being recovered (creating a fake one from scratch to handle the case where it has been destroyed but I want to show some failure analysis gain from it, perhaps), the recovery screen will work right... probably. Just have to figure out HOW to do it :D

Link to comment
Share on other sites

I'm wondering if it will actually display for you, if the results window is using the Squad list of Subjects for its display it might not be possible to get a display, even if you get the data in there. Similarly for the Subjects in the Science Archive

Link to comment
Share on other sites

Where do I get the API's to make plugins, and (aside from Unity and KSP) do I need any other program(s)?

Lots of documentation you can find at http://wiki.kerbalspaceprogram.com/wiki/Community_API_Documentation or at https://github.com/Anatid/XML-Documentation-for-the-KSP-API. You don't need Unity for making plugins (maybe for GUI testing - launching KSP five times per minute after small tweaks is really annoying). But you will need Visual Studio or MonoDevelop for writing a code.

Link to comment
Share on other sites

Lots of documentation you can find at http://wiki.kerbalspaceprogram.com/wiki/Community_API_Documentation or at https://github.com/Anatid/XML-Documentation-for-the-KSP-API. You don't need Unity for making plugins (maybe for GUI testing - launching KSP five times per minute after small tweaks is really annoying). But you will need Visual Studio or MonoDevelop for writing a code.

I got VS 2010, so that's a given.

Thanks for the class code link. Knowing what classes to use has been why I haven't modded any games past .cfg edits yet.

Link to comment
Share on other sites

I've searched the MechJeb sources and found that the following field contains the delta time of the current phys frame: TimeWarp.fixedDeltaTime

However, I still need to find out whether the game is currently paused. Any help?

Link to comment
Share on other sites

I've searched the MechJeb sources and found that the following field contains the delta time of the current phys frame: TimeWarp.fixedDeltaTime

However, I still need to find out whether the game is currently paused. Any help?

FlightDriver.Pause is the one that tells you if times paused - this one is useful sometimes too - PauseMenu.isOpen

Link to comment
Share on other sites

I've searched the MechJeb sources and found that the following field contains the delta time of the current phys frame: TimeWarp.fixedDeltaTime

However, I still need to find out whether the game is currently paused. Any help?

I wouldn't use TimeWarp in that case. Time.fixedDeltaTime is most likely what will do the job in your case.

Link to comment
Share on other sites

Okay, so where are the classes to give players science?

Look at ResearchandDevelopement, ScienceSubject, ScienceData, etc... (i.e. things with research or science in the name).

If you're using Visual Studio you can start typing and let the auto complete suggest things and look through the list. When you find something interesting, F12 on it to jump to it's definition in the assembly.

If you're feeling more adventurous, google ILSpy and use that on the assembly... but while it gives you basically full source disassembly, a lot of the variable names are borked ...

I think we can define new ScienceSubject objects via cfg (see http://forum.kerbalspaceprogram.com/threads/56137-Probe-Science-config-files , probe_science_definitions.cfg ), which we can then generate ScienceData objects referencing the ScienceSubject objects, just shove their config node onto the vessel somewhere (I don't think it matters where, I hacked up a few ScienceData nodes into my persistence file in several places in the vessel hierarchy and got debug log errors about the science subjects not existing when it tried to show the dialog - I haven't yet tried to create them via cfg and haven't figured out how to add them during runtime myself programmatically)...

Link to comment
Share on other sites

Look at ResearchandDevelopement, ScienceSubject, ScienceData, etc... (i.e. things with research or science in the name).

If you're using Visual Studio you can start typing and let the auto complete suggest things and look through the list. When you find something interesting, F12 on it to jump to it's definition in the assembly.

If you're feeling more adventurous, google ILSpy and use that on the assembly... but while it gives you basically full source disassembly, a lot of the variable names are borked ...

I think we can define new ScienceSubject objects via cfg (see http://forum.kerbalspaceprogram.com/threads/56137-Probe-Science-config-files , probe_science_definitions.cfg ), which we can then generate ScienceData objects referencing the ScienceSubject objects, just shove their config node onto the vessel somewhere (I don't think it matters where, I hacked up a few ScienceData nodes into my persistence file in several places in the vessel hierarchy and got debug log errors about the science subjects not existing when it tried to show the dialog - I haven't yet tried to create them via cfg and haven't figured out how to add them during runtime myself programmatically)...

Got it.

One more question. In VS2010, what project type do I select?

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