sarbian Posted July 23, 2013 Share Posted July 23, 2013 (edited) This is an extension for ModuleManager ( http://forum.kerbalspaceprogram.com/showthread.php/31342-0-20-ModuleManager-1-3-for-all-your-stock-modding-needs ).It does not woks when ModuleManager is not installed.ialdabaoth suggested to do extension for things that he don't think fits in the default ModuleManager. This one let you search part with wildcard and conditionals. Most of this code come from ialdabaoth's code.You should be able to do things like searching for "any PART that contains both a ModuleAlternator and a ModuleEngines MODULE and a ModuleGimbal, but only if the ModuleEngines contains an Oxidizer PROPELLANT." @PART[*]:HAS[@MODULE[ModuleEngines]:HAS[PROPELLANT[Oxidizer]],@MODULE[ModuleAlternator],@MODULE[ModuleGimbal]]{xxxxx}Add mechjeb to every probe core, but not to crew capsule (capsule don't use ElectricCharge)@PART[*]:HAS[@MODULE[ModuleCommand]:HAS[@RESOURCE[ElectricCharge]]]{ !MODULE[MechJebCore] MODULE { name = MechJebCore }} Edit all fixed wings @PART[*]:HAS[#module[Winglet]]{ @maxTemp=200}Add MonoPropellant to all tank who don't have any :@PART[*Tank*]:HAS[!RESOURCE[MonoPropellant]]{ RESOURCE { name = MonoPropellant amount = 750 maxAmount = 750 }}Edit all part from the Propulsion category who don't have any SolidFuel and XenonGas@PART[*]:HAS[#category[Propulsion]:HAS[!RESOURCE[SolidFuel],!RESOURCE[XenonGas]]]{ @maxTemp=200}You can also do things like @PART[b9_*] or @PART[b9_Cockpit_???] ( * or ? )Feel free to post any bug with the .cfg file you used, or point out how horrible my code isChangelog : 0.1 : Ready for testing.0.2 : Now you can use ! to check if a module is NOT here, and # to check a properties of the part ( like module = Winglet ) you need to use HAS ( all uppercase ) instead of HasSource : https://github.com/sarbian/MMSarbianExt/Download : http://www.sarbian.com/sarbian/MMSarbianExt.dll Install it by dropping it in the gamedata folder. Put your patch .cfg files anywhere in the gamedata folder or subfolders.Licenced under CC share-alike license. Edited September 1, 2013 by sarbian Link to comment Share on other sites More sharing options...
betaking Posted July 23, 2013 Share Posted July 23, 2013 this would be quite useful for mission controller, in terms of part requirements Link to comment Share on other sites More sharing options...
scottholio Posted July 24, 2013 Share Posted July 24, 2013 Almost missed this, looks like a great idea. I'll be giving this a good look when I get back home. Link to comment Share on other sites More sharing options...
sarbian Posted July 24, 2013 Author Share Posted July 24, 2013 0.2 is released. Can't edit the first post now since the forum is dying with .21 release. Link in first postNow you can use ! to check if a module is NOT here, and # to check a properties of the part ( like module = Winglet )you need to use HAS ( all uppercase ) instead of HasEdit all fixed wings @PART[*]:HAS[#module[Winglet]]{ @maxTemp=200}Add MonoPropellant to all tank who don't have any :@PART[*Tank*]:HAS[!RESOURCE[MonoPropellant]]{ RESOURCE { name = MonoPropellant amount = 750 maxAmount = 750 }}Edit all part from the Propulsion category who don't have any SolidFuel and XenonGas@PART[*]:HAS[#category[Propulsion]:HAS[!RESOURCE[SolidFuel],!RESOURCE[XenonGas]]]{ @maxTemp=200} Link to comment Share on other sites More sharing options...
sidfu Posted July 24, 2013 Share Posted July 24, 2013 anyone got how to get the new .cfg for the new sas to work? in the stock command parts i found the .cfg for the new sas feature but when copied it over it doesnt work. any ideas? Link to comment Share on other sites More sharing options...
Moon Goddess Posted July 25, 2013 Share Posted July 25, 2013 Amazing!!!! I must have this! Link to comment Share on other sites More sharing options...
CreationMe Posted August 13, 2013 Share Posted August 13, 2013 sorry for kinda necroing this, but I was wondering how to add a module to all parts except the parts who already come with this module. For example, I want to add the KASModuleGrab to all parts except the parts who came from KAS itself which already have this module. I tried several things such as @PART[*]:HAS[#MODULE[KASModuleGrab]]{...}or like this @PART[*]:HAS[!MODULE[KASModuleGrab]]{...}or combined them like this@PART[*]:HAS[!#MODULE[KASModuleGrab]]{...}But none of these actually do the trick for me. The first one adds it to everything, and the rest doesn't add anything at all. Can someone please advise me how to pull it off? Link to comment Share on other sites More sharing options...
sarbian Posted August 13, 2013 Author Share Posted August 13, 2013 The second one should do it. If it does not then I messed up.I'll do a quick check tonight but I'am busy until next week. Link to comment Share on other sites More sharing options...
CreationMe Posted August 13, 2013 Share Posted August 13, 2013 Thanks for your quick reply, you don't need to check. Second worked after all. I guess I made some typo or something else, don't know what went wrong. Anyway, it works now. Thanks you very much! Link to comment Share on other sites More sharing options...
Crater Posted August 13, 2013 Share Posted August 13, 2013 I can confirm that the second variant works fine for me. I use it to add MJ, Protractor, and other stuff to command pods, e.g.@PART[*]:HAS[@MODULE[ModuleCommand],!MODULE[MechJebCore]]{ MODULE { name = MechJebCore }}And it does exactly what I would expect.@CreationME: take a look in the KSP.log file. There is a section in there where it tells you what rules and which parts it is matching and applying. Also, try your rule to just patch the new module onto a single part, by name, and see if it works for that one.Edit: lol, you posted while I was typing Link to comment Share on other sites More sharing options...
sarbian Posted August 13, 2013 Author Share Posted August 13, 2013 Less work for me And it's nice to see some people using it, the lack of reply was kinda sad ^^ Link to comment Share on other sites More sharing options...
Crater Posted August 13, 2013 Share Posted August 13, 2013 Less work for me And it's nice to see some people using it, the lack of reply was kinda sad ^^Personally, I'd be lost without it! I used to have a perl script that parsed all the parts and edited/inserted the various modules I wanted, but it was a pain to maintain, and constantly needed tweaking as things changed (I first wrote it against 0.17 part files).Now I just have a handful of rules for your excellent MM extension, and I don't need to worry And when an update to a mod arrives, I just drop it into place, knowing that my deltas will happily apply themselves!Thank you. Link to comment Share on other sites More sharing options...
HoneyFox Posted August 17, 2013 Share Posted August 17, 2013 (edited) This is a must-have extension of MM.I do like the capability to add a module to all parts. Some plugins really need this. Edit: OMG... this plugin corrupted my persistent.sfs... For the first time i get into the game, everything works fine and i have my part module added into all parts. The first launch was also successful. But after i quit the game and restart it, i got an exception when i'm pressing "Resume Saved" on the main menu. It seems to be a check-up failure of part's prototype. I guess the prototype was directly read from the part.cfg, which is different from the one in the persistent.sfs (the one in persistent.sfs has my additional part module).Don't know how to do, and is wondering why other MODs that use basic ModuleManager plugin don't have such issues...Edit2: My fault. Turn out that the issue is on my plugin's side. Again this plugin is awesome! Edited August 18, 2013 by HoneyFox Link to comment Share on other sites More sharing options...
Paul Kingtiger Posted August 22, 2013 Share Posted August 22, 2013 Fantastic mod! Really opens up the possibilities of Module Manger! Link to comment Share on other sites More sharing options...
somnambulist Posted August 24, 2013 Share Posted August 24, 2013 Hi Sarbian, found a bug -- your extension does not match explicitly named parts when that part has no additional pattern matching applied. For testing purposes, all I have installed is a stock install of KSP and the latest version of Module Manager and your extension.@PART[Mark1-2Pod]{ @description = test}Does not work.@PART[*Mark1-2Pod*]{ @description = test}Works.@PART[Mark1-2Pod]:HAS[@MODULE[ModuleCommand]{ @description = test}Works. Link to comment Share on other sites More sharing options...
sarbian Posted August 24, 2013 Author Share Posted August 24, 2013 If there is no *, ? or :HAS my extension won't try to parse it because it should be processed by the normal Modulemanager. Modulemanager does not log as much, so it may just be that the change is done silently. Link to comment Share on other sites More sharing options...
somnambulist Posted August 24, 2013 Share Posted August 24, 2013 If there is no *, ? or :HAS my extension won't try to parse it because it should be processed by the normal Modulemanager. Modulemanager does not log as much, so it may just be that the change is done silently.Then maybe ModuleManager is erroring on the syntax from the extension? My first example does not work when the extension and ModuleManager are loaded, but works fine with only ModuleManager loaded. Link to comment Share on other sites More sharing options...
sarbian Posted August 25, 2013 Author Share Posted August 25, 2013 Ok, I'll need to look at it more then. Thanks for pointing it out Link to comment Share on other sites More sharing options...
sarbian Posted August 25, 2013 Author Share Posted August 25, 2013 I just remembered some post by Majiir I read before my holiday and it may be related ( http://forum.kerbalspaceprogram.com/showthread.php/45107-KSPAddon-bug-causes-mod-incompatibilities ).Just did a new version with that fix. Can you try it ? ( same link http://www.sarbian.com/sarbian/MMSarbianExt.dll ). I'll go sleep on it. Link to comment Share on other sites More sharing options...
somnambulist Posted August 25, 2013 Share Posted August 25, 2013 Just did a new version with that fix. Can you try it ? ( same link http://www.sarbian.com/sarbian/MMSarbianExt.dll ). I'll go sleep on it.Still no good I put a copy of the log up on Pastebin. This is on OS X 10.8.4, but the problem is identical on Win7 64-bit. http://pastebin.com/cHidRCvdNot sure if this is helpful or not, but running the same test w/o your extension leaves an entry 'Applying node /test/@PART[Mark1-2Pod]' in the log file. Link to comment Share on other sites More sharing options...
GavinZac Posted August 26, 2013 Share Posted August 26, 2013 (edited) I love this mod! Makes adding stuff very quick and future-proof. Anyone want to post some of their example configs?// Add kOS to all Command parts that don't already have it@PART[*]:HAS[@MODULE[ModuleCommand]:HAS[!MODULE[kOSProcessor]]]{ MODULE { name = kOSProcessor }}// Add MechJeb to all Command parts that don't already have it@PART[*]:HAS[@MODULE[ModuleCommand]:HAS[!MODULE[MechJebCore]]]{ MODULE { name = MechJebCore }}// Add RemoteTech1 to all Command parts that don't already have it@PART[*]:HAS[@MODULE[ModuleCommand]:HAS[!MODULE[MODULERemoteTechSPU]]]{ MODULE { name = MODULERemoteTechSPU minimumCrew = 0 EnergyDrain = 0.02777778 isRemoteCommand = false }}// Add KAS EVA construction to all parts < 1 ton (Kerbals are mega strong in spaaaace)@PART[*]:HAS[#mass < 1]{ MODULE { name = KASModuleGrab grabKey = g maxDistance = 3 breakForce = 3 evaPartPos = (0.0, 0.1, -0.3) evaPartRot = (10.0, -180.0, 180.0) addPartMass = false grabSndPath = KAS/Sounds/grab } MODULE { name = KASModuleAttach attachKey = h rotateLeftKey = b rotateRightKey = n surfaceDist = 0.169 maxDistance = 3 allowPart = True allowEva = False allowStatic = True sendMsgOnly = False pointerUseModel = True partRot = (-90.0, -15.0, 0.0) attachSndPath = KAS/Sounds/attach detachSndPath = KAS/Sounds/detach }} Edited August 26, 2013 by GavinZac Link to comment Share on other sites More sharing options...
GavinZac Posted August 26, 2013 Share Posted August 26, 2013 I want to try to match all 'manned' command pods, for a very silly reason involving an automatic coffee maker. However, this:@PART[*]:HAS[@MODULE[ModuleCommand]:HAS[#CrewCapacity > 0]]Matches every part in the game. What have I done wrong? Link to comment Share on other sites More sharing options...
sarbian Posted August 26, 2013 Author Share Posted August 26, 2013 Comparator are not supported. Anyway it's strange that it matches all part with that. I'll try at home to check why.But if you want your coffee maker you'll need multiple line. One for each crew capacity@PART[*]:HAS[@MODULE[ModuleCommand]:HAS[#CrewCapacity[1]]{...}@PART[*]:HAS[@MODULE[ModuleCommand]:HAS[#CrewCapacity[2]]{...}@PART[*]:HAS[@MODULE[ModuleCommand]:HAS[#CrewCapacity[3]]{...}Maybe I could add a HAS[#CrewCapacity[>3]. I'll need to check how KSP cfg parser react to < and > first. Link to comment Share on other sites More sharing options...
Starwaster Posted August 26, 2013 Share Posted August 26, 2013 (edited) Comparator are not supported. Anyway it's strange that it matches all part with that. I'll try at home to check why.But if you want your coffee maker you'll need multiple line. One for each crew capacity@PART[*]:HAS[@MODULE[ModuleCommand]:HAS[#CrewCapacity[1]]...Maybe I could add a HAS[#CrewCapacity[>3]. I'll need to check how KSP cfg parser react to < and > first.I'm not fully familiar with your extensions but it seems like there ought to be a way...He's already checking for the presence of a command module so all he should have to do is check that there is NOT a crewCapacity of 0. That should satisfy the conditional... the only way that I can see that it fails is if a part is just missing the property outright and has a command module. Can you check that the property exists at all in addition to checking if it is not 0?Edit: Ok, would THIS let him add his coffee machine using existing syntax?@PART[*]:HAS[@MODULE[ModuleCommand]:HAS[#CrewCapacity[*]]:HAS[!#CrewCapacity[0]]Not clear on if you can combine operators like that.... Edited August 26, 2013 by Starwaster Solution? Link to comment Share on other sites More sharing options...
sarbian Posted August 26, 2013 Author Share Posted August 26, 2013 There is no easier way right now. You can't do that with the current version. I just did some quick test and the problem was in fact easy : there is a missing ] in the expression you posted. Missing square bracket are evil It does not work any better since operators are not implemented but it does not apply to all part.And I checked that < and > are parsed by KSP, so I could add those checks. No guarantee since the code is already more and more messy. Adding much more would need a proper syntax parser and I don't want to go there.I'll add a check for square bracket parity soon. Link to comment Share on other sites More sharing options...
Recommended Posts