Jump to content

The official unoffical "help a fellow plugin developer" thread


Recommended Posts

1 hour ago, jkortech said:

Most of Principia is written in native code (C++) except for a little C# for integrating it into KSP. That's the only one I know. It happens rarely because it is more hassle than it's worth unless you need the speed improvements afforded by having some native code.

Thank you. How would someone go about recompiling a plugin for a newer version of KSP? Should the references for UnityEngine and other dll's point to what's in the game folder? (Of that newer KSP version)

Edited by ShadyAct
Link to comment
Share on other sites

14 minutes ago, ShadyAct said:

Thank you. How would someone go about recompiling a plugin for a newer version of KSP? Should the references for UnityEngine and other dll's point to what's in the game folder? (Of that newer KSP version)

Yep. Just point the references to the versions in the new game folder and compile. Stuff might (and for 1.1 will without question) break in some way and require updated code, so make sure you do some testing before updating the release.

Link to comment
Share on other sites

Part placed would be the GameEvents.OnPartEvent<PartAttach>, note I'm unsure how many times this fires when parts are placed in symmetry.

Somewhere in EditorLogic there is a SelectedPart (PartSelected) object for the current part I believe.

D.

Link to comment
Share on other sites

Hi, hopefully this has not been asked before, but u have not found anything related:

I have a module that allows to deploy/retract a part and changes the crew-capacity while doing so.
The problem i have is that the active contracts do not notice that the crew-capacity has changed the change only takes effect when the scene is reloaded.

Is there a way to trigger the active contracts to update?

I know there is a function called:

Contracts.ContractSystem.Instance.GetCurrentActiveContracts<>

from where i hopefully get the currently active contracts. But i don't know what Class to use for the Generic parameter of this function and if i can trigger an update of a contract from the recieved contracts.

Can someone help me out there? :)  

Edited by Nils277
removed Typo
Link to comment
Share on other sites

How would I make module manager select any part with this module

Spoiler

MODULE
    {
        name = ModuleB9PartSwitch
        moduleID = fuelSwitch
        switcherDescription = Tank Setup
        affectDragCubes = false
        affectFARVoxels = false
        baseVolume = 1500.0

(Specifically, any part with ModuleB9PartSwitch with the fuelSwitch moduleID)

Link to comment
Share on other sites

1 minute ago, Crzyrndm said:

@PART[*]:HAS[@MODULE[ModuleB9PartSwitch]:HAS[#moduleID[fuelSwitch]]]

Probably (NOTE, it's advisable to ask these questions in the mod thread)

Thanks, and I wasn't sure where my question should go so thanks for that too and the quick response.

Link to comment
Share on other sites

Hello, I had a quick question about changes in the 1.0.5 version for modders. Since there is some updates to how heat is handled does this mean there is some new parameters needed for parts to be interacting with heat properly (like the difference between core heat and skin temperature), and if so is there some information about them?

Link to comment
Share on other sites

On 2/22/2016 at 6:22 AM, Nils277 said:

Hi, hopefully this has not been asked before, but u have not found anything related:

I have a module that allows to deploy/retract a part and changes the crew-capacity while doing so.
The problem i have is that the active contracts do not notice that the crew-capacity has changed the change only takes effect when the scene is reloaded.

The parameter type in question is FinePrint.Contracts.Parameters.CrewCapacityParameter.

But you probably don't have to do anything with the contracts specifically. All of these contract parameters have to check for any changes to the vessel (docking, decoupling, parts blowing up, etc...). Try firing the GameEvents.onVesselWasModified event with the current vessel as the argument (GameEvents.onVesselWasModified.Fire(yourVessel);).

That should trigger the parameter to check the vessel again.

 

And I have an unrelated question. 

How do you get the scale value in-game as modified by a part config MODEL{} node?

Link to comment
Share on other sites

3 minutes ago, DMagic said:

How do you get the scale value in-game as modified by a part config MODEL{} node?

My guess is that you'd have to look at the scale of the part's root transform (or the root transform of that particular model).  I don't think KSP stores that information anywhere - it just adds the scaled model and then continues with part loading.

Link to comment
Share on other sites

To answer my own question, it seems that you must look at the second child of the root part transform.

part.transform.getChild(0).getChild(0).localScale;

or 

part.FindModelTransform("model").getChild(0).localScale;

or

part.FindModelTransform(fullPartURL + (Clone)).localScale;

Also note that TweakScale changes the localScale for the "model" transform, the first child of the root part transform. So if you want to take both into account, and you don't want to deal with TweakScale KSPField values, you can access that scale value as well (and probably part.rescaleFactor in case somebody changes that, too).

Link to comment
Share on other sites

@DMagic I was just here. Yes, the transforms under "model" are the individual MODEL nodes, scaled by their individual `scale` factors. The localscale of "model" itself *should* be the `rescaleFactor`, but a bug prior to 1.1 prevents that for MODEL node-based cfgs (it's proper for old mesh based cfgs). Well, prevents it in certain circumstances.

Link to comment
Share on other sites

13 hours ago, DMagic said:

The parameter type in question is FinePrint.Contracts.Parameters.CrewCapacityParameter.

But you probably don't have to do anything with the contracts specifically. All of these contract parameters have to check for any changes to the vessel (docking, decoupling, parts blowing up, etc...). Try firing the GameEvents.onVesselWasModified event with the current vessel as the argument (GameEvents.onVesselWasModified.Fire(yourVessel);).

That should trigger the parameter to check the vessel again.

Thank you! I will try that out when i come home.

I also found a rather hacky solution to that problem just yesterday evening:

/**
 * Update all the contracts with the new crew capacity
 */
private void updateContracts()
{
	//go through all contracts and trigger them to update their status
	foreach (Contracts.Contract contract in Contracts.ContractSystem.Instance.Contracts)
	{
		contract.Reset();
	}
}

Interestingly the contract.Update() methode does not do the trick although one would think it should.
This works and i do not see any side-effects but i think this is a rather bad solution.

I will try out your idea, it seems much cleaner :)

Link to comment
Share on other sites

29 minutes ago, Nils277 said:

Thank you! I will try that out when i come home.

I also found a rather hacky solution to that problem just yesterday evening:


/**
 * Update all the contracts with the new crew capacity
 */
private void updateContracts()
{
	//go through all contracts and trigger them to update their status
	foreach (Contracts.Contract contract in Contracts.ContractSystem.Instance.Contracts)
	{
		contract.Reset();
	}
}

Interestingly the contract.Update() methode does not do the trick although one would think it should.
This works and i do not see any side-effects but i think this is a rather bad solution.

I will try out your idea, it seems much cleaner :)

Caution on that. Are you sure the reset method does not reset partially / completed contract parameters? I'm not sure and unless someone knows for sure I'd test that use case.

Edited by JPLRepo
Link to comment
Share on other sites

Just now, JPLRepo said:

Caution on that. Are you sure the reset method does not reset partially / completed contract parameters? I'm not sure and unless someone knows for sure I'd test that use case.

You are right, it is hard to forsee side-effects of my approach. Thats why i like the suggestion of DMagic much more and will use it :wink:

I have tested my approach and looked at the contracts and what parts of it that have been fulfilled, as well es the contracts time. They do not seem to be reset or influenced, but there could be something reset internally that will only be visible after a long time.

Link to comment
Share on other sites

On 2/24/2016 at 7:07 AM, NathanKell said:

@Nicole core heat applies only to ISRU parts and (slightly) to the RTG. For the main thermo overhaul...not really, no, part cfgs can continue on as before with the same variables as 1.0.4.

That's good news, thanks for the response.

Link to comment
Share on other sites

I want to know whenever a new vessel was launched and how much it cost.

Is onNewVesselCreated the correct game event to subscribe to?

Is there an easy way to get teh total cost of a vessel?

Link to comment
Share on other sites

Hi,

sorry if this question was asked before, I didn't read all 86 pages to see if this question was asked or not, question :

Is there anyway of defining nodes of a part within code itself? the idea is to have a ring that can be scaled using scaling module out there and at the same time, hide and show nodes during the process, the problem is, when i use those two modules from other people's plugins, when i hide nodes in scale 1, then scale it down for example, and show nodes again, the nodes are being placed as if the part is at scale 1.

I would like if there is a way to let user tweak scale by my custom code but at the same time, use the scale to replace nodes so that they show up correctly. Another question is that can we define custom variables in config file to hook it to some internal calculations of the plugin and then use this variable in config to do math? (as an alternative for the fist question and possible solution)

 

thanks

Link to comment
Share on other sites

Hi I just started modding KSP and I found it a little difficult to start. First of all, unlike other games I modded that have useful modding tools to dynamically load/unload plugins on the fly, I have to start/exit the game for every little change I made to see the effect (since I'm a complete newbie I don't know literally anything so I kinda just test them out one by one). Second of all, even though there are a lot of open source projects I can take a look, most of them are quite complicated or poorly documented so they don't offer a lot of help to new modders like me. I went through some intro tutorials without problems but they on the other hand are too basic and don't quite go into details. It would be great to have some basic to mid level tutorials that talk about things like coordinates system, vessel properties, part properties, etc. (KSP API is good but it is not really so accurate and detailed)

Link to comment
Share on other sites

Hi. I am kind of going crazy because I can't find a tutorial of any sort on how to mod ksp. Im not talking just parts but, for example, I want to make my own clouds. I have a good knowledge of unity and c# but there seems to be nothing out there at all. Any suggestions?

Link to comment
Share on other sites

Make clouds for EVE or make a new plugin which adds clouds and related systems? In the first case, I'd suggest asking in the EVE thread or PM'ing rbray. If you want to start from scratch, I'd still suggest picking EVE apart to see how it was done and/or talking with rbray about problems you might encounter.

If you're just looking for a "getting started" the wiki plugin tutorial is still up to date. The only major difference between a part module (which the wiki uses for its example) and a partless plugin is the first two lines of the class

Edited by Crzyrndm
Link to comment
Share on other sites

Hello!

I would like to create a small plugin that can add thing to a KIS inventory.

I browsed the kis, and ose workshop's code and I find out that i can do this with the AddItem() method, but I can't make it working!:confused:

Someone can help me?

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