Jump to content

[Answered] AvailablePart -> Actual part not working as expected.


Recommended Posts

Answer: Turns out the error had nothing to do with AvailablePart. My MM script was misconfigured so the values were in an unamed (and so blank) config sub-node.

 

Alright, something is behaving differently then I expect and I'm not getting anywhere so I'm hoping someone can help out.

I have this line of code:

AvailablePart ap = PartLoader.getPartInfoByName("Mark1-2Pod");
                Debug.Log("2" + ap.partConfig.ToString());

From that ap.partConfig configNode I have these lines:

MODULE
	{
		name = ModuleAutoAction
		                              //Answered: note this blank line and brackets below, this is a config sub-node that shouldn't be here
		{
			activateSAS = True
			activateGroupE = 5
		}
	}

So ModuleManager has correctly added my partModule of ModuleAutoAction and set the two values as I want.

Except they are incorrect when I actually place the part.

This code:

Debug.Log("AutoActs Update");
foreach(Part p in EditorLogic.SortedShipList)
                {
                    if (p.Modules.Contains("ModuleAutoAction"))
                    {
                        ModuleAutoAction maa = (ModuleAutoAction)p.Modules["ModuleAutoAction"];
                        Debug.Log(maa.activateSAS);
                        Debug.Log(maa.activateGroupE);
                    }
                }

when only a single Mk1-2 command pod is placed generates this:

AutoActs Update

False

0

Which are the default values on those KSPFields in my partModule code, not the modified values set by ModuleManager that I want to see.

What am I missing?

The entirety of the code for the partModule in question can be found here.

Anyone have any idea what I'm missing?

D.

Edited by Diazo
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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