Jump to content

The official unoffical "help a fellow plugin developer" thread


Recommended Posts

Oh thank you so much! I've been searching this for hours but I couldn't find anything. It is going to help a lot with coding part. I used the mod back then, but it was annoying for me to add a part to the vessel and then have the first person view. I am trying to avoid that in my mod. Thank you so much again!

EDIT: Unfortunately the mod doesn't come with the source code in it :/ So now, my question is (I know I asked a lot of questions for a tiny little mod but I'm new to C# and modding so please don't mind me :( ) how can I set the interior for KerbalEVA vessel? I read B9 interior source codes and also the stock ones and in all of them the interior file is stated in the Part.CFG so the game knows the interior of that part belongs to internal.cfg. But how can I change information of KerbalEVA so I can assign my interior as internal view in its codes?

You'd ave to locate the KerbalEVA parts present in the universe and add an Internal node to them I believe.

Link to comment
Share on other sites

Trying to find a concise "this is how you start making a plugin" set of instructions was a little difficult. Best one so far that I've found is Cybutek's youtube series. It's from May 2013, but hopefully it's still accurate enough to get me started.

As I understand it, as long as I'm not messing around with models or textures, I don't need Unity or PartTools. If I just want to do stuff in game or use parts supplied (with permission) by other people, I should have the need for Unity/PartTools, correct? So then I would just need a c# IDE such as MS Visual Studio Express.

Are these statements correct? Do I have a basic understand on what is needed?

Link to comment
Share on other sites

Trying to find a concise "this is how you start making a plugin" set of instructions was a little difficult. Best one so far that I've found is Cybutek's youtube series. It's from May 2013, but hopefully it's still accurate enough to get me started.

As I understand it, as long as I'm not messing around with models or textures, I don't need Unity or PartTools. If I just want to do stuff in game or use parts supplied (with permission) by other people, I should have the need for Unity/PartTools, correct? So then I would just need a c# IDE such as MS Visual Studio Express.

Are these statements correct? Do I have a basic understand on what is needed?

That is correct Eadrom, adding models to the game requires Unity/PartTools, but information windows/tool that do background tasks dont need anything but Visual Studio Express for Windows Desktop or Monodevelop.

Some other good resources for starting out are:

and ofcourse this thread and the #KSPModders IRC channel

Link to comment
Share on other sites

This is likely a face-palmingly simple question for more experienced KSP modders, but given I've tried multiple options to no avail, I'd figure I'd ask:

Does anyone know how to access the title associated with a part (eg. "Stayputnik") given a part or partModule within code, rather than the class names or what have you?

I'm likely missing something obvious, but going over the variables in the Part class and trying out a number of them, I can't seem to find it.

EDIT: NM, occurred to me just after I wrote the above that Deadly Reentry was displaying this so I was able to check out its code.

For reference in case anyone else has this issue: part.partInfo.title does the trick.

Edited by FlowerChild
Link to comment
Share on other sites

I have a question (which I think hasn't been asked so far in the thread - forgive me if it has, but I couldn't find it) regarding celestial body properties. I'm currently playing with the RealSolarSystem mod with clouds added to some planets to make them resemble gas giants - but you can still land on them, since their surface behavior hasn't been changed. Do you know of any way to do this, either by changing the surface itself to make it resemble that of Jool, or in some other way? Would it for example be possible, for a certain celestial body, to set an altitude limit below which the vessel explodes or breaks apart?

Link to comment
Share on other sites

I haven't looked into that myself--do you usually break apart at a certain altitude for Jool? I thought I'd seen pics of people "landed" on Jool so thought not. I also didn't see any likely variable for that in CelestialBody when I was first writing RSS. What you might want to do is write a partmodule that checks vessel's pressure outside, and starts breaking parts if pressure gets too high (maybe hook into crashTolerance as a hack for determining how strong parts are). The Deadly Reentry source would be a great place to start--in fact, maybe it should just be added as a third check (beyond heat and G force) in the DRE main loop...

Link to comment
Share on other sites

I haven't looked into that myself--do you usually break apart at a certain altitude for Jool? I thought I'd seen pics of people "landed" on Jool so thought not. I also didn't see any likely variable for that in CelestialBody when I was first writing RSS. What you might want to do is write a partmodule that checks vessel's pressure outside, and starts breaking parts if pressure gets too high (maybe hook into crashTolerance as a hack for determining how strong parts are). The Deadly Reentry source would be a great place to start--in fact, maybe it should just be added as a third check (beyond heat and G force) in the DRE main loop...

Well, I've never actually tried going into Jool's atmosphere deep enough to notice any such effects, but I've seen those videos as well. I looked at the API wiki for CelestialBody and couldn't see anything either. I guess it's not possible to change the planets' surfaces into Jool-like surfaces, so the "break apart at a certain altitude" option was more of a backup plan in case that wouldn't work. I would prefer if the property was bound to the CelestialBody and not to the vessel, but I guess that may not be possible in that case.

Link to comment
Share on other sites

To make a Gas giant out of a planet, I think you can destroy its PQS, as Jool doesn't have one. But I think that might cause bad things to happen (especially to PQSCity's)... I should test one day XD

Edited by KCreator
giant != gaint
Link to comment
Share on other sites

Oh, yeah. That's true. I kinda misinterpreted the question I guess.

No worries, I see what you mean - and it might work, but even though it depends on a property of the CelestialBody, the code that gives the desired effect would still be "attached" to the part, right?

To make a Gas giant out of a planet, I think you can destroy its PQS, as Jool doesn't have one. But I think that might cause bad things to happen (especially to PQSCity's)... I should test one day XD

That would be a neat solution if possible! The planets/moons that I'd like to convert to gas giants don't have any easter eggs or other such things on them that I'm aware of, so PQSCity issues shouldn't matter, right? Or is PQSCity used for anything else apart from placing static objects like easter eggs? (I'm quite new to the plugin coding thing as you can probably tell, so please forgive any stupid questions :P)

Edited by lunait
Link to comment
Share on other sites

lunait: attached, yes, but...just try out Deadly Reentry if you haven't yet. You'll get what I mean.

There's two things: *looking* like a gas giant, and actually adding pressure damage. For the former, removing PQS will work. For the latter, it's as we discussed: AFAIK no built-in pressure damage.

Link to comment
Share on other sites

I'm getting my feet wet with just doing cfg editing for now, and I have a question regarding the Science Experiments.

I'm wanting to change the baseValue for a science experiment (for example, Crew Report), and I'm not sure how to directly override the value in the ScienceDefs.cfg. I have tried using @EXPERIMENT_DEFINITION[crewReport] within my own .cfg file, yet it doesn't appear to work. I have managed to get somewhat close to what I'm looking for by creating my own Experiment (ie a near copy of the entire Crew Report definition) and changing the basic Command cockpit to referencing my experiment instead, but I am hopeful there is a way to directly change the Crew Report fields without directly changing the ScienceDefs.cfg itself.

Link to comment
Share on other sites

Add a partmodule to (at least something on) the vessel, and override OnSave

I can't do that, this is a part less mod and I don't want to use module manager, I saw something called OnGameSceneChangeRequested or something like that, but I cant Get it to work.

Link to comment
Share on other sites

Requires changes to ModuleManager. They're tagged by id, not name. Oh Squad, ever consistent.

I figured out how to do change the Experiment definitions without changing anything else. :cool:


@EXPERIMENT_DEFINITION[*]:HAS[#id[crewReport]]
{
@baseValue = 50
@scienceCap = 50
}

Link to comment
Share on other sites

Does the KSPField Attribute work with all ConfigNodes, or just MODULE ones?

EDIT: I did a test, it doesn't work. Another question though, how can I call a function just before switching vessels, I need to write some vessel data to a config.

Edited by MrHappyFace
Link to comment
Share on other sites

Is there a way to tell through code when a Science Lab (or whatever is making use of the Science Lab's transmission boost variable) has finished processing some ScienceData?

Secondary Question: How do you add a method to GameEvents? Say I'm wanting to do something like this:


public class ModuleResearchExperiment : ModuleScienceExperiment
{

public override void OnStart(PartModule.StartState state)
{
base.OnStart(state);
GameEvents.onPartActionUICreate.Add(someEvent)
}
public void someEvent(){
Debug.Log("This event occurred");
}


}

How would I go about supplying the correct argument to add to the GameEvents queue?

Edited by Rhidian
Link to comment
Share on other sites

Does anyone know how to return the name of the your current biome (either on the surface or flying above)?

I was thinking it must be something like the vessel.mainBody.name type of thing, but nothing I've tried works.

I tried

print(vessel.orbit.referenceBody.BiomeMap.Map.name);

but it just returns "kerbin_biomes_quantized" or mun, or whatever body you're orbiting. The same happens with vessel.mainBody.

vessel.landedAt will return KSC, but it doesn't seem to work for anything else.

There must be some way to check which biome you're in. Anyone have any ideas?

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