Jump to content

Adding functionality to a part by copying MODULE entry


suicidemission

Recommended Posts

Background: I have no experience modding KSP but I figured I'd give it a go to learn a little bit by doing something I've wanted to for a long time- adding the "Ore" scanning function from Extraplanetary Launchpad's magnetometer to the much prettier magnetometer from DMagic Science Parts. According to the CFG File Documentation and "Changing Part Configuration Files" pages on the KSP wiki it should be as simple as copying the MODULE from the EL part to the DMagic part. Seems that, nope, that's not gonna do it.

Here's what I was copying:

MODULE
{
name = KethaneDetector
DetectingPeriod = 1.5
DetectingHeight = 60000
PowerConsumption = 0.4
Resource
{
Name = Ore
}
}

I dropped that inside the PART {} at the end of the DMagic CFG, the same way it appears inside the EL CFG but... de nada. No such module appears in the editor or on the ship once launched. My new magnetometer doesn't magnetowhatever.

I also tried to make a copy of the part and adjust the references inside the CFG so it looked like a second part, identical but with added functionality. Also de nada.

Did I completely misunderstand the tutorials? Is there some functionality I'm overlooking or a conflict? I'll post the CFG details from both in the post below.

Link to comment
Share on other sites

Welcome to the forums! :)

As this is cfg modding, rather than the specific 'writing a plugin' topic for this subforum, I'm moving this back to Addon Development.

First, I would suggest making your changes via Module Manager. That's what it's for. You can create a cfg file, stick it somewhere in GameData, and do

@PART[name_of_part_to_modify] // where that name is found by looking the cfg for the name = whatever line.
{
MODULE
{
name = KethaneDetector
DetectingPeriod = 1.5
DetectingHeight = 60000
PowerConsumption = 0.4
Resource
{
Name = Ore
}
}
}

That will add that new node to the part.

As for cloning, you can do

+PART[name_of_source_part]
{
@name = new_name_for_new_part
// whatever other changes you want to make
}

Link to comment
Share on other sites

LOL go figure, I thought diving into Module Manager would be the hard way! Thanks Nathan.

I decided my first foray into modding would be to mess around with some CFGs to get the hang of them. Next I plan on cooking up some improved models for a few parts. I have a WIP smelter for EL I'm hoping to configure for use with Near Future's heat sink mechanic, so understanding how CFG tweaking and Module Manager worked was pretty important.

This is the first one I'm working on- an improved smelter model for Extraplanetary Launchpads, visually based on IRL smelters. Exported to SketchUp for a quick texture job to get an idea for appearances without having to unwrap and paint the UV map. I'm gonna try to get the tricount down by giving the pipes fewer sides (they have 12 at present, I think 9 will be enough visually), modifying the 1.25m 45deg ports (which are intended for mounting heat sinks for use with the Near Future "Thermal Load" mechanic), removing one of the radial tanks and making the 2.5m radial attach points flush with the body near the 3m bottom. At present it's about 7000 but I think I can make some improvements and get it down to 2000-3000 or so while keeping the overall similarity with IRL smelters intact. I'll be redoing the CFG to make the smelter's characteristics more similar to IRL smelters as well, based on the improved smelters settings from a smelter model I found here on the forums.

aUFVePE.jpg

Thanks again NathanKell! A journey of a thousand miles started with this single step! :)

Link to comment
Share on other sites

Okay, so experimenting a little I tried this:

+PART[stackDecouplerMini]
{
@name = stackDecouplerMini-NoForce
title = TR-2VNF Stack Decoupler
description = The TR-2VNF Stack Decoupler is a miniature detachment utility for small rockets and space probes that separates the payload but does not exert any force upon it.

MODULE
{
name = ModuleDecouple
ejectionForce = 0
explosiveNodeID = top
}
}

But when I ran KSP the new "no force" decoupler showed:

Decoupler Force: 0

Decoupler Force: 15

So reading through the ModuleManager docs on GitHub I found the Edit operator but copying the node, modifying it to remove ejectionForce = 15 and modifying it again to add ejectionForce = 0 did nothing (I still saw both values in the editor). Do I suck at computer? I think I suck at computer.

Link to comment
Share on other sites

I've started playing with config files too - not sure I have a firm grasp on MM yet so take this with a grain of salt.

I think you need a @ in front of all the fields you want to modify.

If I understand this right:

+PART[stackDecouplerMini]
{
// Find the name field and change to stackDecouplerMini-NoForce
@name = stackDecouplerMini-NoForce
// Find the title field and change...
@title = TR-2VNF Stack Decoupler
// Find the description field and change...
@description = The TR-2VNF Stack Decoupler is a miniature detachment utility for small rockets and space probes that separates the payload but does not exert any force upon it.

// Find the MODULE with name = ModuleDecouple - not sure if this will do all or just the first
@MODULE[ModuleDecouple]
{
// In MODULE[ModuleDecouple] find the ejectionForce field and change...
@ejectionForce = 0
// In MODULE[ModuleDecouple] find the explosiveNodeID field and change...
@explosiveNodeID = top
}
}

Link to comment
Share on other sites

So re-reading the way MM handles operators the default is INSERT, so if no operator is specified it adds it, which is why my second attempt created two values- I wasn't using the @ operator to edit the values, I was using +MODULE -MODULE but not modifying the operators within the values. Since it's not necessary to edit any MODULE values besides ejectionForce within ModuleDecouple, I cut out everything else and obtained this, which functions as intended:

+PART[stackDecouplerMini]
{
@name = stackDecouplerMini-NoForce
@title = TR-2VNF Stack Decoupler
@description = The TR-2VNF Stack Decoupler is a miniature detachment utility for small rockets and space probes that separates the payload but does not exert any force upon it.

@MODULE[ModuleDecouple]
{
@ejectionForce = 0
}

}

I'm going to start experimenting with the modified CFGs and EL's native textured primitive smelter tomorrow and see if I can get it working as intended. After that I'll start learning the MM method of configuring the attachment nodes before I finalize the model and start the texturing process.

Edited by suicidemission
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...