Jump to content

Ways to view stock module code for reference?


Recommended Posts

I'm new to modding and would like to try to write a plugin, and I've been doing some reading about it on the forums and Wiki, but I can't seem to find where to look at some stock modules to base mine off of. Specifically I'm looking for MultiModeEngine and the ModuleEngineFX documentation. Is there a way to look at the stock code for these, or a resource that I could look at that explains them? I tried the API site but there is nothing about MultiModeEngine..

Thanks!

Link to comment
Share on other sites

You are however allowed to look at other mods' code, and maybe we can help you find some apt examples.

What specifically are you looking to do?

Ok, what I am trying to do is create a module similar to MultiModeEngine (or extend it somehow) that allows the modder to enable toggling of more than 2 engine modes. In theory it could be unlimited, but practically an engine wouldn't probably have more than 3 or 4. I created a 5 nozzled engine in my mod QuizTech that allows 5 nozzles active or 1 nozzle active modes, but I'd like to add a third option which would toggle a 4 nozzle mode. If there is already a plugin that does this then I'd be just as happy to implement that, but if not, I think it would be worth the exercise in plugin development to try and figure out how to make it :)

Edited by Quiznos323
Link to comment
Share on other sites

Well, there's a handful of things you'll need:

Learn how to consume resources: part.RequestResource(), you can see it in use in a lot of mods, if the mod uses a custom partmodule to consume or generate fuel, this is how they do it, unless they don't because RequestResource() is really annoying.

Learn how to work with transforms: as I expect you're familiar with, the thrustTransform of each engine bell is responsible for orienting the particle system and representing the thrust's position, and another transform is used for gimballing the thrust transform, you're going to need to replicate all of that.

Learn how to apply a force: Best thing I can point you to for that is ModuleRCSFX https://github.com/NathanKell/ModuleRCSFX/blob/master/Source/ModuleRCSFX.cs

I don't know it's code myself, but it's relatively small and simple, and it's made by some of the best modders in KSP so it should be really good.

Learn how to take values from cfg files, I don't have a good example for this but it shouldn't be too hard to find

And once you know all that you'll be able to replicate the old ModuleEngine, not sure how the mode thing works but others can help.

If you want a faster conversation you could come to IRC://IRC.Esper.net/KSPModders and chat with a lot of knowledgable people more directly.

Link to comment
Share on other sites

Thanks for the info! Hopefully I think all I may need is to be able to call which ModuleEngineFX blocks to use, but if I need to expand/build it like you described I will try haha. I'm new to all of this so we'll see what I can do XD

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