Cephei

The official unoffical "help a fellow plugin developer" thread

Recommended Posts

16 hours ago, zer0Kerbal said:

it gets easier (or so I hope *knocking on wood*)

are you using github desktop? @AmpCat

I am. Also the visual studio git plugin.

Share this post


Link to post
Share on other sites

Is it possible for me to use the unity package manager API to install a package into ksp using a c# script. I have experience with unity, but little with ksp, so any help would be much appreciated.

Share this post


Link to post
Share on other sites

As far as I know you can not. The package API is only available in the editor. And some package seems to require some configuration in the game data files. Which package did you want to add?

Share this post


Link to post
Share on other sites

I was thinking to try add the post processing stack if that would be possible.

Share this post


Link to post
Share on other sites

I'm just updating to 1.8 and hit a snag.  I've got code that's trying to load a button image, but the old Texture2D.LoadImage method is no longer a thing.  (See my example of what used to work in my GetButtonTexture method).

Anybody got a pointer to a different way to load a texture in 1.8?  Thanks.

Derp, got my own answer by RTFM:

 

Edited by NermNermNerm
answered my own question

Share this post


Link to post
Share on other sites
On 10/22/2019 at 5:33 AM, peteletroll said:

@Lisias, do you plan to file a bug soon? Probably UI_FloatRange, UI_ScaleEdit and UI_FloatEdit have the same root bug. I can file it for you too, maybe someone from @SQUAD can suggest the best way to get this fixed soon.

Hey, I have hard evidences (i.e, proof!!) that I may had misdiagnosed the cause of the problem!

nbbk9N7.png

When the scaling is being called from BDB.dll, it works. When it's called from TweakScale, it does not.

Right now, I'm sniffing into BDB source code to see what it does (or does not) differently from the rest of us.

Edited by Lisias
Kraken count the tyops! (and the grammars!)

Share this post


Link to post
Share on other sites

I have a new diagnosis, and this one is backed by hard, concrete and reproducible evidences. :) 

The whole story is on TweakScale thread, because one fellow Kerbonaut found one Add'On where the UI_ScaleEdit was working fine!! I tracked down what was working, then I made it broke, then I "fix" one of TweakScale patches - so I have confirmation on both sides of the equation this time.

[KSPField(isPersistant = false, guiActiveEditor = true, guiName = "Scale", guiFormat = "0.000", guiUnits = "m")]
[UI_ScaleEdit(scene = UI_Scene.Editor)]

The thing I think by now can be the problem is the guiUnits (or even the guiFormat?), but it's all wild guesses. All that I know for now is that is on the TweaklScale thread - there's a ScaleType from BDB that works while default ScaleTypes from TweakScale does not. The visible difference is not using the ScaleRtpe data called "suffix" - I will check this properly tomorrow.

See ya later.

Share this post


Link to post
Share on other sites

Hi all,

I would like to figure out how much science something returns from a certain location if the experiment was recovered or transmitted using these objects: ScienceData data and ScienceExperiment experiment.
I know that data.subjectID gives me a string experimentID@location, and experiment.baseValue and experiment.scienceCap are the base values, but I do not know how to calculate the science at a location with these.

Does someone here know?

(edit: of course I could test all experiments at all locations and hardcode a solution, but I'm looking for a simple algorithm or api call)

edit2: probably solved, just discovered that the ResearchAndDevelopment class has a bunch of science value related methods like ResearchAndDevelopment.GetScienceValue(dataAmount, scienceSubject)

 

edit3: So here's my next question I haven't been able to figure out:

I have a confignode CONTAINED_DATA in which an unknown amount of entries (of the form subjectID:dataAmount) are stored, which looks like this:

CONTAINED_DATA
{
	atmosphereAnalysis@KerbinFlyingLowShores = 200
	atmosphereAnalysis@KerbinSrfLandedLaunchPad = 200
	asdf = 42
}

I have been trying to get my code to add these entries to a dictionary called containedData by looping over the nodes in CONTAINED_DATA:

foreach (ConfigNode dataNodeKey in dataNode.GetNodes())
{
    string key = dataNodeKey.ToString();
    float value = float.Parse(dataNode.GetValue(key));
    containedData.Add(key, value);
    Debug.Log(key + " was added to the dictionary");
}

However, nothing gets added to this dictionary and the log mentions nothing about added keys. I have also tried looping over dataNode.nodes and returning a bunch of objects, which all seem to be empty. Here is the log with comments:

[LOG 22:28:57.178] OnLoad called //the onload method is called in my partmodule
[LOG 22:28:57.178] MODULE //the node is dumped to the log
{
	name = ModuleDataContainer
	isEnabled = True
	stagingEnabled = True
	EVENTS
	{
	}
	ACTIONS
	{
	}
	CONTAINED_DATA //the node (called dataNode in the code) where various entries are stored, which are not known in advance
	{
		atmosphereAnalysis@KerbinFlyingLowShores = 200
		atmosphereAnalysis@KerbinSrfLandedLaunchPad = 200
		asdf = 42
	}
	UPGRADESAPPLIED
	{
	}
}

[LOG 22:28:57.178] GetNodes: ConfigNode[] //dataNode.GetNodes().ToString() returns what seems to be an empty list of confignodes
[LOG 22:28:57.178] nodes.tostring: ConfigNode+ConfigNodeList //dataNode.nodes.ToString() returns something I can't decipher
[LOG 22:28:57.178] Values: System.String[] //dataNode.GetValues().ToString() returns what seems to be an empty list of strings
[LOG 22:28:57.178] This really should work: 200 //directy accessing an entry does work but is not usable when entries are unknown
[LOG 22:28:57.178] containedData is empty //nothing got added to the dictionary
[LOG 22:28:57.178] OnLoad finished

What can I loop over to add the entries to my dictionary and how?

edit4: I created a workaround so that key and value are stored separately (which is a lot less practical), but I still hope there is a solution for key = value entries with unknown keys

Edited by ExtremeTrader

Share this post


Link to post
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.