Jump to content

Module Manager syntax & changing textures without editing models


Recommended Posts

Hey, so I have a few personal tweaks I make to some of the mods I use and I recently decided that I should create module manager patches to apply these tweaks so I don't have to go edit the cfg files in the mods every time they update.

However, I'm not totally fluent in module manager syntax and the github wiki pages on it don't have examples for everything so I just wanted to post the patches I'm working on here to make sure I'm doing stuff properly.For one patch, I wanted to make all the parts which use or store MetalOre use Ore instead, however, the patch didn't seem to do anything, here it is:

@PART[*]:NEEDS[Launchpad]:Final
{ 
@ResourceName.*[MetalOre]{@name = Ore}
}

@PART[HexCanOreHuge]:NEEDS[Launchpad]:Final
{ 
@title = HexCan-Ore-Huge
@description = A 6m long resource canister containing Ore
}

@PART[HexCanOreLarge]:NEEDS[Launchpad]:Final
{ 
@title = HexCan-Ore-Large
@description = A 3m long resource canister containing Ore
}

@PART[HexCanOre]:NEEDS[Launchpad]:Final
{ 
@title = HexCan-Ore
@description = A 1.5m long resource canister containing Ore
}

@PART[HexCanOreSmall]:NEEDS[Launchpad]:Final
{ 
@title = HexCan-Ore-Small
@description = A 0.75m long resource canister containing Ore
}


@PART[ELTankLargeORE]:NEEDS[Launchpad]:Final
{ 
@title = MSV-2000 Ore Container
}

@PART[ELTankMedORE]:NEEDS[Launchpad]:Final
{ 
@title = MSV-1000 Ore Container
}

@PART[ELTankSmlORE]:NEEDS[Launchpad]:Final
{ 
@title = MSV-500 Ore Container
}

I've checked and double checked my syntax and by all accounts this looks to me as if it should work, however it has no effect ingame.Secondly, I wanted to disable Progressive Builds in EL, since as far as I can tell you can't disable them anymore, and with crewed vessels this seems to have worked, but unfortunately I can't seem to figure out how to allow probe operated vessels with no crew build ships. I tried both setting IgnoreCrewCapacity to true and removing IgnoreCrewCapacity altogether and neither seemed to have any effect. Let me know if there's actually a way to disable Progressive Builds (including allowing probes to build stuff) as I'll just do that, however, if there isn't, I imagine this patch will come in handy to a number of people.

@PART[*]:NEEDS[Launchpad]:HAS[@MODULE[ExWorkshop]]:Final
{
@MODULE[ExWorkshop] {
    @ProductivityFactor = 1000000
    //@IgnoreCrewCapacity = true
    !IgnoreCrewCapacity.*  // I wanted to allow building things without Kerbals but I can't seem to get it working.
    }
}
@EXPERIENCE_TRAIT[Pilot]:NEEDS[Launchpad] {
    EFFECT {
        name = ExConstructionSkill
    }
}

@EXPERIENCE_TRAIT[Scientist]:NEEDS[Launchpad] {
    EFFECT {
        name = ExConstructionSkill
    }
}

@EXPERIENCE_TRAIT[Tourist]:NEEDS[Launchpad] {
    EFFECT {
        name = ExConstructionSkill
    }
}

Furthermore, this patch seems to be conflicting with another I made to allow you to build Rocketparts from the Survey Station (and build rockets there too), seemingly making the addition of a building rocketparts void. See below:

@PART[ExSurveyStation]:NEEDS[Launchpad]
{
    MODULE {
        name = ExWorkshop // Allows you to actually build ships
        ProductivityFactor = 2.5
    }

    MODULE {
    // Only produces parts at half the speed of the full workshop,
    // but it allows for building smaller ships and bases.
        name = ExConverter
        StartActionName = Start Part Production
        StopActionName = Stop Part Production
        INPUT_RESOURCE {
            ResourceName = Metal
            Ratio = 0.00975
        }
        INPUT_RESOURCE {
            ResourceName = ElectricCharge
            Ratio = 5
        }
        OUTPUT_RESOURCE {
            ResourceName = RocketParts
            Ratio = 0.35
        }
    }
}

 

Lastly, back in 0.25, I had made a stockalike retexture of the workshop from Extraplanetary Launchpads by changing the blue to a light grey. I wanted to bring this forward to my current build of the game and again, I was hoping to only do this with a simple modulemanager patch so I don't have to reapply the edit every time EL updates. Unfortunately, the patch I wrote doesn't seem to do anything. See below:

@PART[ExWorkshop]:NEEDS[Launchpad]
{
    @MODEL {
        texture = ExLtweaks/Textures/Workshop/Hatch, ExLtweaks/Textures/Workshop/Hull
    }
}

I'm hoping to release these patches as I imagine others may enjoy playing with them, but I of course need them to work first! Thanks for any help I can get. I'm getting the hang of modulemanager a lot more now and am really enjoying both modding and playing the 1.1.+ branch. :)

Link to comment
Share on other sites

Well, your first config refers to a module called "ResourceName", which isn't found in any part. I don't think the ".*" is valid syntax, either (though I could be wrong). Try:

// Fix resource storage
@PART:HAS[@RESOURCE[MetalOre]]:NEEDS[Launchpad]:Final
{ 
	@RESOURCE[MetalOre]
	{
		@name = Ore
	}
}

// Fix resource conversion
@PART:HAS[@MODULE[ExExtractor]]:NEEDS[Launchpad]:Final
{ 
	@MODULE[ExExtractor]:HAS[#ResourceName[MetalOre]]
	{
		@ResourceName = Ore
	}
}

// Fix resource conversion
@PART:HAS[@MODULE[ExConverter]]:NEEDS[Launchpad]:Final
{ 
	@MODULE[ExConverter]
	{
		@INPUT_RESOURCE:HAS[#ResourceName[MetalOre]]
		{
			@ResourceName = Ore
		}
		@OUTPUT_RESOURCE:HAS[#ResourceName[MetalOre]]
		{
			@ResourceName = Ore
		}
	}
}

// Fix resource detection
@PART:HAS[@MODULE[KethaneDetector]]:NEEDS[Launchpad]:Final
{ 
	@MODULE[KethaneDetector]
	{
		@Resource:HAS[#Name[MetalOre]] {
			@Name = Ore
		}
	}
}

// Fix resource detection
@PART:HAS[@MODULE[ModuleResourceScanner]]:NEEDS[Launchpad]:Final
{ 
	@MODULE[ModuleResourceScanner]:HAS[#ResourceName[MetalOre]]
	{
		@ResourceName = Ore
	}
}

// Fix resource detection
@PART:HAS[@MODULE[ModuleAnalysisResource]]:NEEDS[Launchpad]:Final
{ 
	@MODULE[ModuleAnalysisResource]:HAS[#resourceName[MetalOre]]
	{
		@resourceName = Ore
	}
}

(The :HAS on the top-level parts is not strictly necessary, and prevents you from having one @PART block around everything else, but why should ModuleManager have to carefully scan each and every part that's unrelated to resources or EPL?)

BTW, you may need to adjust the ratios on ExConverter for the modified conversions to stay balanced. I'm not sure if that was an oversight or not.

For the second patch, the experience and productivity patches appear to be correct. For the unmanned bit, try either "%IgnoreCrewCapacity = true" (the old version did nothing if the config did not have IgnoreCrewCapacity) or "!IgnoreCrewCapacity = anyvalue" (the old version should have been marked as invalid, as it had neither = nor {}). I can't comment on whether these changes will actually enable probe builds, it's been a long time since I've played EPL.

The biggest problem with the third patch is that it's run in the second round of MM patches (since you don't give a :FIRST, :FINAL, :BEFORE, :FOR, or :AFTER). Since ExSurveyStation is itself created by a MM patch in :AFTER[Launchpad], the part does not exist at the time you're trying to modify it. Since you need to force execution after :AFTER[Launchpad], I'd suggest using either :FINAL or :FOR[<my-mod-name-that's-alphabetically-after-L>]. A second problem is that the station already has an ExWorkshop, so after your patch there will be two. My final recommendation is

@PART[ExSurveyStation]:NEEDS[Launchpad]:FINAL
{
    @MODULE[ExWorkshop] {
        %ProductivityFactor = 2.5
    }

    MODULE {
    // Only produces parts at half the speed of the full workshop,
    // but it allows for building smaller ships and bases.
        name = ExConverter
        StartActionName = Start Part Production
        StopActionName = Stop Part Production
        INPUT_RESOURCE {
            ResourceName = Metal
            Ratio = 0.00975
        }
        INPUT_RESOURCE {
            ResourceName = ElectricCharge
            Ratio = 5
        }
        OUTPUT_RESOURCE {
            ResourceName = RocketParts
            Ratio = 0.35
        }
    }
}

(I *really* wish MM had a way to say "create a module by this name or modify it if it already exists", but as far as I know doesn't.)

I can't help much with the fourth patch, because I know nothing about part models. Reading GameData/ModuleManager.ConfigCache (which is an excellent MM debugging method, I highly recommend it), the modified ExWorkshop config has:

MODEL
{
	model = ExtraplanetaryLaunchpads/Parts/Workshop/workshop
	position = 0.0, 0.0, 0.0
	rotation = 0.0, 0.0, 0.0
	scale = 1.0, 1.0, 1.0
	texture = ExLtweaks/Textures/Workshop/Hatch, ExLtweaks/Textures/Workshop/Hull
}

Is that what it's supposed to look like?

Edited by Starstrider42
Link to comment
Share on other sites

8 hours ago, Starstrider42 said:

snip

Hey, thanks for the in depth writeup. I'm going over my patches now and I see where I've gone wrong in a lot of places. Also, you were right, "period+asterix" is not proper syntax, I mistook it for "comma+asterix" which searches all keys of the name you specified and edits them all. It's in the module manager handbook.

As for the ore stuff, I'm gonna take a look into the converters and do the math to make sure the balancing is right for the final patch, thanks for reminding me of that. I'm also gonna try changing the " @ " to " % " for the descriptions and titles and see if that works.

As for the Survey Station, I forgot that it already had a workshop, so I'm just gonna exclude those lines from my patch, as they seem to conflict with the DisableProgressiveBuilds patch I made. I added ":Final" to the patch too, so it should hopefully actually apply now.

Finally, with the texture replacer, that is what I wanted the patch to do, but since changing the texture paths in the part file doesn't seem to do anything, I might just give up and open the model in unity to manually change the texture. It's not ideal as it's more work for me and I have to redistribute a modified model that is essentially the same, but I suppose if there's no other way to change the texture without replacing the original it's what I'll have to do.

Link to comment
Share on other sites

39 minutes ago, Markelius said:

Finally, with the texture replacer, that is what I wanted the patch to do, but since changing the texture paths in the part file doesn't seem to do anything, I might just give up and open the model in unity to manually change the texture. It's not ideal as it's more work for me and I have to redistribute a modified model that is essentially the same, but I suppose if there's no other way to change the texture without replacing the original it's what I'll have to do.

It may not be exactly what you want it to do, and it would require adding the Firespitter or B9 plugin .dlls as a dependency, but both those mods have texture switchers... I know the Firespitter one works in-game, allowing texture switches in the editor, simply, using the right-click menu...

There is an excellent document explaining the .cfg modules for Firespitter somewhere on the Git repo...

Here's an example of using the FSTextureSwitch2 in the DeadSkins textures for AviationLights (sorry for the long folder names...lol):
 

@PART[lightbeacon_amber]
{
	MODULE
		{
			name = FStextureSwitch2
			textureNames = AviationLights/Parts/lights/model000beacon_amber;DeadSkins/model000beacon_amber-clear;DeadSkins/model000beacon_amber-fisheye;DeadSkins/model000beacon_amber-glass;DeadSkins/model000beacon_amber-pyramid;DeadSkins/model000beacon_amber-square
			objectNames = light
			textureDisplayNames = Original;Clear;Fisheye;Glass;Pyramid;Square
			statusText = Current Texture
			showPreviousButton = false
		}
}

 

Edited by Stone Blue
Link to comment
Share on other sites

9 hours ago, Starstrider42 said:

(I *really* wish MM had a way to say "create a module by this name or modify it if it already exists", but as far as I know doesn't.)

Isn't that what the % operator is for? According to the documentation @ is for modifying if it exists, and % is for modify if exist else create it.

Edited by Warezcrawler
Link to comment
Share on other sites

40 minutes ago, Markelius said:

Hey, thanks for the in depth writeup. I'm going over my patches now and I see where I've gone wrong in a lot of places. Also, you were right, "period+asterix" is not proper syntax, I mistook it for "comma+asterix" which searches all keys of the name you specified and edits them all. It's in the module manager handbook.

As for the ore stuff, I'm gonna take a look into the converters and do the math to make sure the balancing is right for the final patch, thanks for reminding me of that. I'm also gonna try changing the " @ " to " % " for the descriptions and titles and see if that works.

The Wiki is helpful, but I think ,* (btw, asterisk ≠ Asterix) might not actually be needed any more -- the default behavior is to mod everything that matches. When I tested your patches, the descriptions and titles appeared to be fine -- it was only the actual resources that didn't get changed.

1 minute ago, Warezcrawler said:

Isn't that what the % operator is for? According to the documentation @ is for modifying if it exists, and % is for modify if exist else create it.

In my experience that only works for values. I posted about it on the MM thread a while back but didn't get any answers that weren't workarounds.

Link to comment
Share on other sites

Okay, my edits to the patches are going well, I got the names and descriptions on things to change, and my DisableProgressiveBuilds patch seems to be working, I couldn't get builds without a crew to work, but hey, I'll take my success for now.

I'm gonna finish writing the ore patch and then I should be able to release my mod. I have this mod to tweak extraplanetary launchpads and another to disable the core heat system on ISRU's and Drills (which is working perfectly).

I'll post in this thread again if I hit another snag, but I think it's just a matter of finishing touches now, thanks for the help! I appreciate it. :)

Link to comment
Share on other sites

Hey, I'm back. :P I seem to have gotten all my tweaks working except a few things with the metalore to ore patch. The way you're supposed to handle modifying entries that are nested under other entries is confusing me so I know I'm probably doing something wrong here. The names and descriptions of stuff changed, but the smelters don't work and the ore containers do store ore now, but they also store metalore as well? Don't know what's happening there. I modified the Augers too but I haven't gotten a chance to test them since I'm pretty sure in all my time playing Extraplanetary Launchpads I've always used Roverdude's drills or stock drills.

Anyways, here's my patch:
 

@PART[*Auger]:NEEDS[Launchpad]:Final
{ 
	@MODULE[ExExtractor]:HAS[#ResourceName[MetalOre]]
	{
		@ResourceName = Ore //With how tough the EL Augers are to use, I don't think their ratio needs to be changed.
	}
}

//Below section changes resource storage containers and modifies their titles and descriptions.

@PART:HAS[@RESOURCE[MetalOre]]:NEEDS[Launchpad]:Final
{ 
	@RESOURCE[@name[MetalOre]]
	{
		@name = Ore
	}
}

@PART[HexCanOreHuge]:NEEDS[Launchpad]:Final
{ 
@title = HexCan-Ore-Huge
@description = A 6m long resource canister containing Ore
}

@PART[HexCanOreLarge]:NEEDS[Launchpad]:Final
{ 
@title = HexCan-Ore-Large
@description = A 3m long resource canister containing Ore
}

@PART[HexCanOre]:NEEDS[Launchpad]:Final
{ 
@title = HexCan-Ore
@description = A 1.5m long resource canister containing Ore
}

@PART[HexCanOreSmall]:NEEDS[Launchpad]:Final
{ 
@title = HexCan-Ore-Small
@description = A 0.75m long resource canister containing Ore
}


@PART[ELTankLargeORE]:NEEDS[Launchpad]:Final
{ 
@title = MSV-2000 Ore Container
}

@PART[ELTankMedORE]:NEEDS[Launchpad]:Final
{ 
@title = MSV-1000 Ore Container
}

@PART[ELTankSmlORE]:NEEDS[Launchpad]:Final
{ 
@title = MSV-500 Ore Container
}


//use Simpleconstruction ratio for turning ore into metal (ie. 1 ore + 60 ElectricCharge = 0.5 metal)
//tiny smelter should produce metal at 0.4x the rate, & small smelter should at 0.7937005259840998x (round to 0.8) the rate.

@PART[Smelter]
{
	@MODULE [ExConverter] {
		@INPUT_RESOURCE:HAS[@ResourceName[MetalOre]] {
		@ResourceName = Ore
		@Ratio = 1.0
		}
		
		@INPUT_RESOURCE:HAS[@ResourceName[ElectricCharge]] {
		@Ratio = 60
		}
		
		@OUTPUT_RESOURCE:HAS[@ResourceName[Metal]] {
		@Ratio = 0.5
		}
}
}

@PART[SmallSmelter]
{
	@MODULE [ExConverter] {
		@INPUT_RESOURCE:HAS[@ResourceName[MetalOre]] {
		@ResourceName = Ore
		@Ratio = 0.8
		}
		
		@INPUT_RESOURCE:HAS[@ResourceName[ElectricCharge]] {
		@Ratio = 48
		}
		
		@OUTPUT_RESOURCE:HAS[@ResourceName[Metal]] {
		@Ratio = 0.4
		}
}
}

@PART[TinySmelter]
{
	@MODULE [ExConverter] {
		@INPUT_RESOURCE:HAS[@ResourceName[MetalOre]] {
		@ResourceName = Ore
		@Ratio = 0.4
		}
		
		@INPUT_RESOURCE:HAS[@ResourceName[ElectricCharge]] {
		@Ratio = 24
		}
		
		@OUTPUT_RESOURCE:HAS[@ResourceName[Metal]] {
		@Ratio = 0.2
		}
}
}

// Fix resource detection
@PART:HAS[@MODULE[KethaneDetector]]:NEEDS[Launchpad]:Final
{ 
	@MODULE[KethaneDetector]
	{
		@Resource:HAS[#Name[MetalOre]] {
			@Name = Ore
		}
	}
}

// Fix resource detection
@PART:HAS[@MODULE[ModuleResourceScanner]]:NEEDS[Launchpad]:Final
{ 
	@MODULE[ModuleResourceScanner]:HAS[#ResourceName[MetalOre]]
	{
		@ResourceName = Ore
	}
}

// Fix resource detection
@PART:HAS[@MODULE[ModuleAnalysisResource]]:NEEDS[Launchpad]:Final
{ 
	@MODULE[ModuleAnalysisResource]:HAS[#resourceName[MetalOre]]
	{
		@resourceName = Ore
	}
}

 

EDIT: Okay, I messed with the patch but it didn't seem to do anything, descriptions and titles still work but the resource storage doesn't, and neither do the smelters. I think the smelters store ore now but they also store metal ore? Honestly I'm gonna call it a night for now. I have something else in mind that might work but I'll try it tomorrow Here's the updated code:

@PART[*Auger]:NEEDS[Launchpad]:Final
{ 
	@MODULE[ExExtractor]:HAS[#ResourceName[MetalOre]]
	{
		@ResourceName = Ore //With how tough the EL Augers are to use, I don't think their ratio needs to be changed.
	}
}

//Below section changes resource storage containers and modifies their titles and descriptions.

@PART:HAS[@RESOURCE[@name[MetalOre]]]:NEEDS[Launchpad]:Final
{ 
	@RESOURCE[@name[MetalOre]]
	{
		@name = Ore
	}
}

@PART[HexCanOreHuge]:NEEDS[Launchpad]:Final
{ 
@title = HexCan-Ore-Huge
@description = A 6m long resource canister containing Ore
}

@PART[HexCanOreLarge]:NEEDS[Launchpad]:Final
{ 
@title = HexCan-Ore-Large
@description = A 3m long resource canister containing Ore
}

@PART[HexCanOre]:NEEDS[Launchpad]:Final
{ 
@title = HexCan-Ore
@description = A 1.5m long resource canister containing Ore
}

@PART[HexCanOreSmall]:NEEDS[Launchpad]:Final
{ 
@title = HexCan-Ore-Small
@description = A 0.75m long resource canister containing Ore
}


@PART[ELTankLargeORE]:NEEDS[Launchpad]:Final
{ 
@title = MSV-2000 Ore Container
}

@PART[ELTankMedORE]:NEEDS[Launchpad]:Final
{ 
@title = MSV-1000 Ore Container
}

@PART[ELTankSmlORE]:NEEDS[Launchpad]:Final
{ 
@title = MSV-500 Ore Container
}


//use Simpleconstruction ratio for turning ore into metal (ie. 1 ore + 60 ElectricCharge = 0.5 metal)
//tiny smelter should produce metal at 0.4x the rate, & small smelter should at 0.7937005259840998x (round to 0.8) the rate.

@PART[Smelter]
{
	@INPUT_RESOURCE,0 {
		@ResourceName = Ore
		@Ratio = 1.0
		}
		
	@INPUT_RESOURCE,1 {
		@Ratio = 60
		}
		
	@OUTPUT_RESOURCE,0 {
		@Ratio = 0.5
		}
}
}

@PART[SmallSmelter]
{
	@INPUT_RESOURCE,0 {
		@ResourceName = Ore
		@Ratio = 0.8
		}
		
	@INPUT_RESOURCE,1 {
		@Ratio = 48
		}
		
	@OUTPUT_RESOURCE,0 {
		@Ratio = 0.4
		}
}
}

@PART[TinySmelter]
{
	@INPUT_RESOURCE,0 {
		@ResourceName = Ore
		@Ratio = 0.4
		}
		
	@INPUT_RESOURCE,1 {
		@Ratio = 24
		}
		
	@OUTPUT_RESOURCE,0 {
		@Ratio = 0.2
		}
}
}

// Fix resource detection
@PART:HAS[@MODULE[KethaneDetector]]:NEEDS[Launchpad]:Final
{ 
	@MODULE[KethaneDetector]
	{
		@Resource:HAS[#Name[MetalOre]] {
			@Name = Ore
		}
	}
}

// Fix resource detection
@PART:HAS[@MODULE[ModuleResourceScanner]]:NEEDS[Launchpad]:Final
{ 
	@MODULE[ModuleResourceScanner]:HAS[#ResourceName[MetalOre]]
	{
		@ResourceName = Ore
	}
}

// Fix resource detection
@PART:HAS[@MODULE[ModuleAnalysisResource]]:NEEDS[Launchpad]:Final
{ 
	@MODULE[ModuleAnalysisResource]:HAS[#resourceName[MetalOre]]
	{
		@resourceName = Ore
	}
}

.

Edited by Markelius
Link to comment
Share on other sites

The expression "@RESOURCE[@name[MetalOre]]" looks for something like:

RESOURCE {
	name = @name[MetalOre]
}

which doesn't exist. You need to use "@RESOURCE[MetalOre]", like in the first example I listed, or "@RESOURCE:HAS[#name[MetalOre]]", note the # and :HAS.

All your smelter patches have too many closing braces, which causes KSP to skip reading the rest of the file.

Possibly related, your smelter patches don't mention ExConverter, so they look for resource nodes that are directly under the part. Try, e.g.,

@PART[Smelter]
{
	@MODULE[ExConverter] {
		@INPUT_RESOURCE,0 {
			@ResourceName = Ore
			@Ratio = 1.0
			}
			
		@INPUT_RESOURCE,1 {
			@Ratio = 60
			}
			
		@OUTPUT_RESOURCE,0 {
			@Ratio = 0.5
			}
	}
}

That should be it.

Link to comment
Share on other sites

Okay, thanks a lot for showing me what was wrong, I was tired last night and was sure I was making some kind of dumb mistakes somewhere.

So now everything seems to work, only problem is while the containers show up in the Utility section and if you search for them, they won't show up in the "EL Items" section anymore. I can't seem to figure out why this is or how you define parts to be in that category in the first place, and it's inconvenient, but not a deal breaker. I think I'll release the mod today and if I can find a fix for making the ore containers show up in that category again, I will. If not, it's not the end of the world, the rest still works great. Thanks for all the 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...