Jump to content

Set "control from here" for part from plugin


Recommended Posts

That's what I thought. So tried this:


ModuleCommand tModuleCommand = new ModuleCommand();
tModuleCommand = part.Modules.OfType<ModuleCommand>().FirstOrDefault();

tModuleCommand.MakeReference();

I am able to change variables of for example ModuleEngines so I thought this would do the trick and I've activated methods in other classes before but MakeReference is the name of the KSPEvent so could it be that the method has a different name or is there some other noob oversight here?

Link to comment
Share on other sites

That's what I thought. So tried this:


ModuleCommand tModuleCommand = new ModuleCommand();
tModuleCommand = part.Modules.OfType<ModuleCommand>().FirstOrDefault();

tModuleCommand.MakeReference();

I am able to change variables of for example ModuleEngines so I thought this would do the trick and I've activated methods in other classes before but MakeReference is the name of the KSPEvent so could it be that the method has a different name or is there some other noob oversight here?

KSPEvents are just normal methods with a KSPEvent attribute slapped onto it.

Link to comment
Share on other sites

KSPEvents are by default named after the method. That method is tagged with the event attribute.

Presumably something went wrong when you tried it? What was that? Did the log have anything to say?

p.s. You don't need to create a new ModuleCommand when declaring a variable. ModuleCOmmand tModuleCommand; is sufficient.

Link to comment
Share on other sites

... Presumably something went wrong when you tried it? What was that? Did the log have anything to say? ...

It fails to compile saying ModuleCommand does not contain a definition or method for MakeReference. I've got the feeling I'm overlooking something else here.

I have achieved the same goal with:

vessel.SetReferenceTransform(part);

So for now I'm good, but everybody thanks for all your help.

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