Jso Posted May 3, 2020 Share Posted May 3, 2020 10 minutes ago, ns88ns said: Hi, community. A quick question: is there a way/method to check whether an other node is defined from root path? E.g.: I would like to apply patch to a part only in case if a resource is already defined: @PART[MyCoolPart]:AFTER[OtherCoolMod] { (all the stuff) } but only if root node RESOURCE_DEFINITION[ResName] exists already? Thank you in advance. Typically you would use :NEEDS[CommunityResourcePack] or whatever mod defines the resource in question. I'm not aware of any way to test for a condition outside the PART other than NEEDS. Quote Link to comment Share on other sites More sharing options...
linuxgurugamer Posted May 9, 2020 Share Posted May 9, 2020 Hi, Having a problem with a mod, I suspect this is the problem: @PART[~kerbalEVA*]:HAS[@MODULE[ModuleScienceExperiment],!MODULE[WBI*]] This is supposed to apply to any part which doesn't contain "kerbalEVA*", but I don't think it's working I actually need to exclude all of the following: Quote maleEVA femaleEVA kerbalEVA_RD_Exp kerbalEVA_female_Exp kerbalEVA_RD_Future kerbalEVA_female_Future kerbalEVA kerbalEVAfemale kerbalEVAVintage kerbalEVAfemaleVintage. kerbalEVAFuture kerbalEVAfemaleFuture Suggestions? Quote Link to comment Share on other sites More sharing options...
Jso Posted May 9, 2020 Share Posted May 9, 2020 30 minutes ago, linuxgurugamer said: @PART[~kerbalEVA*]:HAS[@MODULE[ModuleScienceExperiment],!MODULE[WBI*]] This is supposed to apply to any part which doesn't contain "kerbalEVA*", but I don't think it's working This would be my guess: @PART:HAS[~name[kerbalEVA*],@MODULE[ModuleScienceExperiment],!MODULE[WBI*]] Quote Link to comment Share on other sites More sharing options...
linuxgurugamer Posted May 9, 2020 Share Posted May 9, 2020 (edited) 1 hour ago, Jso said: This would be my guess: @PART:HAS[~name[kerbalEVA*],@MODULE[ModuleScienceExperiment],!MODULE[WBI*]] Ok. What about this: @PART:HAS[~name[kerbalEVA*],~name[*maleEVA],@MODULE[ModuleScienceExperiment],!MODULE[WBI*]] That will cover all the EVA kerbals I listed earlier, just not sure about the leading asterick Edit: This is now working, thanks @Jso Edited May 9, 2020 by linuxgurugamer Quote Link to comment Share on other sites More sharing options...
linuxgurugamer Posted May 9, 2020 Share Posted May 9, 2020 (edited) [deleted, wrong thread] Edited May 9, 2020 by linuxgurugamer Quote Link to comment Share on other sites More sharing options...
Wyzard Posted May 9, 2020 Share Posted May 9, 2020 1 hour ago, linuxgurugamer said: New release, 0.11.19 I think you meant to post this in the All Y'All thread. Quote Link to comment Share on other sites More sharing options...
Citizen247 Posted May 12, 2020 Share Posted May 12, 2020 Is there a way to only apply a patch if a variable is set to a value? Like if #$@MY_MODS_SETTINGS/USE_SETTING$ was set to true than certain patches should be applied, otherwise they're ignored? Like NEEDS but for variables? Quote Link to comment Share on other sites More sharing options...
4x4cheesecake Posted May 12, 2020 Share Posted May 12, 2020 33 minutes ago, Citizen247 said: Is there a way to only apply a patch if a variable is set to a value? Like if #$@MY_MODS_SETTINGS/USE_SETTING$ was set to true than certain patches should be applied, otherwise they're ignored? Like NEEDS but for variables? As far as I know, you cannot check for variables in other nodes to apply a patch to something different. I tried it and failed miserably but I did something like that for my own config for simple fuel switch by adding the value from the settings to the parts I wanted to modify and then checking for the value in the actual patch. For example: Config file: My_Mod_Settings { change_this = true } 1. Patch: //This must adress everything which may or may not be patched depending on the settings //Use multiple patches like this if you cannot adress everything in a single patch @PART[*]:HAS[whatever_it_is_you_want_to_adress] { //Dummy Module MODULE { name = my_dummy change_this = #$My_Mod_Settings/change_this$ } } 2. Patch: //Actual patch to apply your changes @PART[*]:HAS[@MODULE[my_dummy]:HAS[#change_this[true]]] { //do whatevery you want to do } 3. Patch: //Cean up @PART[*]:HAS[@MODULE[my_dummy]] { !MODULE[my_dummy] {} } Quote Link to comment Share on other sites More sharing options...
Citizen247 Posted May 12, 2020 Share Posted May 12, 2020 Thanks. I wonder if that approach would work by adding a dummy property rather than a module? Quote Link to comment Share on other sites More sharing options...
4x4cheesecake Posted May 12, 2020 Share Posted May 12, 2020 2 hours ago, Citizen247 said: Thanks. I wonder if that approach would work by adding a dummy property rather than a module? Should work as well, it's just important that you add the value you want to check for to the config node you want to modify. I've used a module because I had quite a few values to add and thought it would be more elegant to put all of them into a single module Quote Link to comment Share on other sites More sharing options...
Ja222 Posted May 12, 2020 Share Posted May 12, 2020 (edited) I am trying to add ablator to some of the parts since x6.4 scale reentries get pretty hot for unshielded parts. I wrote the code, but it doesn't work and to be honest I have no idea where I made a mistake. Spoiler @PART[*]:HAS[#category[Ground]], HAS[#category[Structural], HAS[#category[FuelTank], HAS[#category[Aero], HAS[!MODULE[ModuleAblator]]] { @MODULE { name = ModuleAblator ablativeResource = Ablator lossExp = -7500 lossConst = 0.1 pyrolysisLossFactor = 6000 reentryConductivity = 0.01 ablationTempThresh = 500 useChar = True charModuleName = shieldChar } @RESOURCE { name = Ablator amount = 0 maxAmount = 50 } } @PART[*gear*] { @MODULE { name = ModuleAblator ablativeResource = Ablator lossExp = -7500 lossConst = 0.1 pyrolysisLossFactor = 6000 reentryConductivity = 0.01 ablationTempThresh = 500 useChar = True charModuleName = shieldChar } @RESOURCE { name = Ablator amount = 0 maxAmount = 50 } } ModuleAblator used is stock Squad module pulled from one of the heatshields. If I understand the syntax correctly, I want to: 1. Find all parts that belong to ground,structural, fuelTank and aero category... 1a. That do not already have a ModuleAblator. 2. Add ModuleAblator to those parts. 3. Add ablator resource set to start at 0 and max out at 50 units. 4. Do the same for all parts that have "gear" in name. But I seem to be missing something, and I am all out of ideas. Edited May 12, 2020 by Ja222 Quote Link to comment Share on other sites More sharing options...
Corax Posted May 13, 2020 Share Posted May 13, 2020 @MODULE{name = ModuleAblator …} You'll need to remove the '@', since that is the modifier operator and there's nothing there to modify yet. Same for @RESOURCE{…}. Quote Link to comment Share on other sites More sharing options...
Jognt Posted May 13, 2020 Share Posted May 13, 2020 14 hours ago, Ja222 said: I am trying to add ablator to some of the parts since x6.4 scale reentries get pretty hot for unshielded parts. I wrote the code, but it doesn't work and to be honest I have no idea where I made a mistake. Hide contents @PART[*]:HAS[#category[Ground]], HAS[#category[Structural], HAS[#category[FuelTank], HAS[#category[Aero], HAS[!MODULE[ModuleAblator]]] { @MODULE { name = ModuleAblator ablativeResource = Ablator lossExp = -7500 lossConst = 0.1 pyrolysisLossFactor = 6000 reentryConductivity = 0.01 ablationTempThresh = 500 useChar = True charModuleName = shieldChar } @RESOURCE { name = Ablator amount = 0 maxAmount = 50 } } @PART[*gear*] { @MODULE { name = ModuleAblator ablativeResource = Ablator lossExp = -7500 lossConst = 0.1 pyrolysisLossFactor = 6000 reentryConductivity = 0.01 ablationTempThresh = 500 useChar = True charModuleName = shieldChar } @RESOURCE { name = Ablator amount = 0 maxAmount = 50 } } ModuleAblator used is stock Squad module pulled from one of the heatshields. If I understand the syntax correctly, I want to: 1. Find all parts that belong to ground,structural, fuelTank and aero category... 1a. That do not already have a ModuleAblator. 2. Add ModuleAblator to those parts. 3. Add ablator resource set to start at 0 and max out at 50 units. 4. Do the same for all parts that have "gear" in name. But I seem to be missing something, and I am all out of ideas. It doesn’t work because of step 1: It’s trying to find all parts that match ALL of the criteria. Which are 0 parts. Your next thought would be to replace the comma with a pipe, but you cannot filter with pipes in a HAS block. You’ll need to chop it up into 1 patch per category, or find a different property to filter by. Also, @ is used to target an existing key/node. Since no specifier is given your @MODULE would modify the first module in the part. Since you want to add a new module, ditch the @. Quote Link to comment Share on other sites More sharing options...
Ja222 Posted May 13, 2020 Share Posted May 13, 2020 (edited) Thank you for answers Unfortunately, I still seem to fail at implementing my code. Spoiler @PART[*]:HAS[category[Aero]] { RESOURCE { name = Ablator amount = 0 maxAmount = 50 } MODULE { name = ModuleAblator ablativeResource = Ablator lossExp = -7500 lossConst = 0.1 pyrolysisLossFactor = 6000 reentryConductivity = 0.01 ablationTempThresh = 500 useChar = false } } Code in the spoiler above goes without an error on load, and still does not add ablator resource to the parts in hangar. I modified the stock ModuleAblator with simple "false" flag to useChar - it is pretty self explanatory. I dropped @'s as mentioned. Maybe I need to mark the patch as FINAL to make it work? I don't think I have any mod that would mess with it but I'll try. Edited May 13, 2020 by Ja222 Quote Link to comment Share on other sites More sharing options...
Corax Posted May 13, 2020 Share Posted May 13, 2020 You're not specifying a filter qualifier: @PART[*]:HAS[#category[Aero]]{…}; note the '#' hash mark, you'll want to look for all parts containing a KEY named CATEGORY with a value of AERO here. Quote Link to comment Share on other sites More sharing options...
Ja222 Posted May 13, 2020 Share Posted May 13, 2020 Thank you, that one worked. Quote Link to comment Share on other sites More sharing options...
blowfish Posted May 15, 2020 Share Posted May 15, 2020 On 5/12/2020 at 2:02 PM, Ja222 said: I am trying to add ablator to some of the parts since x6.4 scale reentries get pretty hot for unshielded parts. I wrote the code, but it doesn't work and to be honest I have no idea where I made a mistake. Hide contents @PART[*]:HAS[#category[Ground]], HAS[#category[Structural], HAS[#category[FuelTank], HAS[#category[Aero], HAS[!MODULE[ModuleAblator]]] { @MODULE { name = ModuleAblator ablativeResource = Ablator lossExp = -7500 lossConst = 0.1 pyrolysisLossFactor = 6000 reentryConductivity = 0.01 ablationTempThresh = 500 useChar = True charModuleName = shieldChar } @RESOURCE { name = Ablator amount = 0 maxAmount = 50 } } @PART[*gear*] { @MODULE { name = ModuleAblator ablativeResource = Ablator lossExp = -7500 lossConst = 0.1 pyrolysisLossFactor = 6000 reentryConductivity = 0.01 ablationTempThresh = 500 useChar = True charModuleName = shieldChar } @RESOURCE { name = Ablator amount = 0 maxAmount = 50 } } Okay so Don't put spaces in there. KSP doesn't like them. Nothing MM can do about this short of completely rewriting the parser. There's unfortunately no way to do multiple categories like that. They have to be separate patches (or something like that) Only one top level HAS is allowed, any conditions have to be within that You seem to want to add the MODULE and RESOURCE, so get rid of the @ on each of them - @ is for editing an existing node, not adding a new one Quote Link to comment Share on other sites More sharing options...
HafCoJoe Posted May 20, 2020 Share Posted May 20, 2020 (edited) Greetings! I set up a MM patch to replace the title of two BDArmory parts, though my patch doesn't work for some reason, and I can't figure out why. Nvm! My modules were correct but the mod includes :FINAL tags on its part names for some reason. Edited May 20, 2020 by Avera9eJoe Quote Link to comment Share on other sites More sharing options...
Jso Posted May 20, 2020 Share Posted May 20, 2020 17 minutes ago, Avera9eJoe said: Greetings! I set up a MM patch to replace the title of two BDArmory parts, though my patch doesn't work for some reason, and I can't figure out why. Make sure the file is under GameData someplace. Check the file extension and make sure it's actually .cfg and not .cfg.doc or whatever wordpad uses (folder options uncheck hide extentions for known file type or something along those lines). Use Notepad or get NotePad++ for editing text files. Quote Link to comment Share on other sites More sharing options...
HafCoJoe Posted May 20, 2020 Share Posted May 20, 2020 (edited) 5 hours ago, Jso said: Make sure the file is under GameData someplace. Check the file extension and make sure it's actually .cfg and not .cfg.doc or whatever wordpad uses (folder options uncheck hide extentions for known file type or something along those lines). Use Notepad or get NotePad++ for editing text files. It's already fixed, my patch was correct but BDA had strange custom patches that included :FINAL in the titles, so my patches weren't showing up Edited May 20, 2020 by Avera9eJoe Quote Link to comment Share on other sites More sharing options...
KrakenBeGone Posted May 22, 2020 Share Posted May 22, 2020 Instead of copying a part and deleting what I don't want, can I create a new part and add modules referenced in another part? +MODULE[<what does a reference to a module in another part look like>] {} Can I also encapsulate a NEEDS and HAS statement around several parts? :NEEDS[<whatever mod>] { PART {} PART {} } Quote Link to comment Share on other sites More sharing options...
blowfish Posted May 22, 2020 Share Posted May 22, 2020 (edited) 2 hours ago, KrakenBeGone said: Instead of copying a part and deleting what I don't want, can I create a new part and add modules referenced in another part? +MODULE[<what does a reference to a module in another part look like>] {} Yes, but you have to do it in a patch (MM doesn't look for anything but NEEDS in the orignal node Spoiler PART { name = somePart MODULE { name = ModuleSomething } } PART { name = someOtherPart } @PART[someOtherPart] { #@PART[somePart]/MODULE[someModule] {} } 2 hours ago, KrakenBeGone said: Can I also encapsulate a NEEDS and HAS statement around several parts? no Edited May 22, 2020 by blowfish Quote Link to comment Share on other sites More sharing options...
linuxgurugamer Posted May 22, 2020 Share Posted May 22, 2020 (edited) Hi all, Would like a little help here. I need a patch to find all instances of one string and replace it with another. This is to repoint some part textures to a new location for a texture. Very specifically, I need this: texture = orange-jumbo-0, Squad/Parts/FuelTank/fuelTankJumbo-64/model000 texture = orange-jumbo-1, Squad/Parts/FuelTank/fuelTankJumbo-64/model001 changed to this: texture = orange-jumbo-0, FuelTanksPlus/Squad/fuelTankJumbo-64/model000 texture = orange-jumbo-1, FuelTanksPlus/Squad/fuelTankJumbo-65/model001 I'm a bit busy, and don't have time to puzzle this out, would appreciate any help Thanks LGG Edit: I have this working, but it's ugly: @PART[*]:NEEDS[FuelTanksPlus] { @MODEL { @texture,0 ^= :Squad/Parts/FuelTank/fuelTankJumbo-64:FuelTanksPlus/Squad/fuelTankJumbo-64: @texture,1 ^= :Squad/Parts/FuelTank/fuelTankJumbo-64:FuelTanksPlus/Squad/fuelTankJumbo-64: @texture,2 ^= :Squad/Parts/FuelTank/fuelTankJumbo-64:FuelTanksPlus/Squad/fuelTankJumbo-64: @texture,3 ^= :Squad/Parts/FuelTank/fuelTankJumbo-64:FuelTanksPlus/Squad/fuelTankJumbo-64: } } When I didn't have the ,[0123], it only touched the first texture line, so I added the additional lines. Is there a better way? Edited May 22, 2020 by linuxgurugamer Quote Link to comment Share on other sites More sharing options...
blowfish Posted May 22, 2020 Share Posted May 22, 2020 4 hours ago, linuxgurugamer said: When I didn't have the ,[0123], it only touched the first texture line, so I added the additional lines. Is there a better way? should be as simple as @texture,* Quote Link to comment Share on other sites More sharing options...
linuxgurugamer Posted May 22, 2020 Share Posted May 22, 2020 5 minutes ago, blowfish said: should be as simple as @texture,* Thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.