Jump to content

Accessing MechJeb


Recommended Posts

So, I'm trying to find out how I can have my mod check to see if a MechJeb box is installed on the vessel that my mod is running on, and then access it's MechJebCore so I can utilize the surface coordinates of the landing sub-module. The issue is that after two days of trying, first by just winging it, second by studying GravityTurn's MechJebWrapper, I've came up with nothing. Is there anyone on here who can give me a rundown on how to check and access one module from another, separate one? I've already tried making a few foreach loops to parse my parts for the module, but that doesn't seem to be returning anything.

Link to comment
Share on other sites

Well I haven't looked into accessing MJ2. But you can normally get a class reference by

part.FindModulesImplementing<myModule>();	--> gives a list of the modules in the part
part.FindModuleImplementing<myModule>();	--> gives the first module in the part

where myModule is the module you are trying to manipulate or access information from. Examples of modules are "ModuleResourceHarvester", "ModuleResourceConverter" etc. Or in your case "MechJebCore".

EDIT:

And maybe you should check if mechjeb2 is installed at all, something like this

bool isThatModLoaded = AssemblyLoader.loadedAssemblies.Any(a => a.name == "TheModName");

 

Edited by Warezcrawler
Link to comment
Share on other sites

I actually contacted AndyMt, and consulted with him about how his GravityTurn mod is able to access Mechjeb in order to circularize, and while I think that's managed to get me the mechjebcore I need, I cant seem to access it's variables. Neither GetField or GetValue seem to be working for me.

Link to comment
Share on other sites

5 hours ago, Tompete Kerman said:

I actually contacted AndyMt, and consulted with him about how his GravityTurn mod is able to access Mechjeb in order to circularize, and while I think that's managed to get me the mechjebcore I need, I cant seem to access it's variables. Neither GetField or GetValue seem to be working for me.

Could you provide examples on what you do? Maybe its something simple.

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