Apaseall Posted October 19, 2018 Share Posted October 19, 2018 6 minutes ago, blowfish said: You want %J = #$@F[g]/h$ to paste a variable from a different top-level node (@ tells it to look at the top level) You're missing the /h part :HAS is not valid when creating a node. It checks the node you're modifying, so if you had @MODULE:HAS[...] that would check the conditions on the existing MODULE node See 3 Thanks. So code would like this: Spoiler Code in b.cfg is: I { name = something //some stuff %J = #$@F[G]/H$ //create variable MODULE:NEEDS[#J[H]] { // some more stuff, including name = say foo } !J = 0 // delete variable } What I am thinking is that b.cfg is the definition file for a part called something. I am trying to add a module to something depending on the value of H. How about I use a :NEEDS that checks the value of #J? Quote Link to comment Share on other sites More sharing options...
Jesusthebird Posted October 19, 2018 Share Posted October 19, 2018 4 hours ago, Burning Kan said: Thanks for the warning ,test it when i start my kerbalismcareer(few weeks),i dont want to use MKS that why i need to deploy with EC AFAIK in ksp all is calculated in metric tons so 1kg is 0.001 and nice ,will try it with engineer depency when the time come ,Cheers Hmm. Using the original patch..the ec to deploy the pilgrim was 6750. Which i was only able to double check using the kg value per this post. Im probably missing something obvious..just not to me lol Quote Link to comment Share on other sites More sharing options...
blowfish Posted October 19, 2018 Share Posted October 19, 2018 5 hours ago, Apaseall said: Thanks. So code would like this: Hide contents Code in b.cfg is: I { name = something //some stuff %J = #$@F[G]/H$ //create variable MODULE:NEEDS[#J[H]] { // some more stuff, including name = say foo } !J = 0 // delete variable } What I am thinking is that b.cfg is the definition file for a part called something. I am trying to add a module to something depending on the value of H. How about I use a :NEEDS that checks the value of #J? NEEDS only checks the presence or absence of mods. You'll need to split this into multiple patches. I think this is what you want F { g = h } @PART[something] // whatever your patch actually is { %j = #$@F[g]/h$ } @PART[something]:HAS[#j[h]] { MODULE { // ... } } @PART[something]:HAS[#j[*]] { !j = del // del part can be anything, just needs to be an equal sign here } Quote Link to comment Share on other sites More sharing options...
Apaseall Posted October 19, 2018 Share Posted October 19, 2018 4 minutes ago, blowfish said: NEEDS only checks the presence or absence of mods. You'll need to split this into multiple patches. I think this is what you want. Oh. Can I get away with: Spoiler a.cfg F { g = h } b.cfg PART // whatever my part { name = something // lots of lovely stuff for the part %j = #$@F[g]/h$ } @PART[something]:HAS[#j[h]] { MODULE { // ... } } @PART[something]:HAS[#j[*]] { !j = del // del part can be anything, just needs to be an equal sign here } Since b.cfg is a part definition file, it will be creating part whose name = something. The first piece of b.cfg then would be creating a part, the second piece would be amending that part? Hmm. Lots of thoughts come to me here. Irrespective of you answer to the code in this post, I might be able to swing what I am looking for in the use I am aiming at. But would be nice to know if this code IS an option. Oh and blowfish, you are a STAR. My sincerest thanks for sharing your knowledge with me. Quote Link to comment Share on other sites More sharing options...
blowfish Posted October 19, 2018 Share Posted October 19, 2018 1 minute ago, Apaseall said: Oh. Can I get away with: Hide contents a.cfg F { g = h } b.cfg PART // whatever my part { name = something // lots of lovely stuff for the part %j = #$@F[g]/h$ } @PART[something]:HAS[#j[h]] { MODULE { // ... } } @PART[something]:HAS[#j[*]] { !j = del // del part can be anything, just needs to be an equal sign here } Since b.cfg is a part definition file, it will be creating part whose name = something. The first piece of b.cfg then would be creating a part, the second piece would be amending that part? Hmm. Lots of thoughts come to me here. Irrespective of you answer to the code in this post, I might be able to swing what I am looking for in the use I am aiming at. But would be nice to know if this code IS an option. Oh and blowfish, you are a STAR. My sincerest thanks for sharing your knowledge with me. You do have to put it in a patch. Variable replacements and other MM things aren't processed on non-patch root level nodes (i.e. PART { }). This may change at some point in the future but is the case for now. Quote Link to comment Share on other sites More sharing options...
Apaseall Posted October 19, 2018 Share Posted October 19, 2018 (edited) 9 minutes ago, blowfish said: You do have to put it in a patch. Variable replacements and other MM things aren't processed on non-patch root level nodes (i.e. PART { }). This may change at some point in the future but is the case for now. Hmm. So if for example I had b.cfg as a part definition file, which is .cfg, then I would do things in this order: Spoiler 1. Let the part def file run. i.e. b.cfg. 2. Have file (c.cfg) named such that it executes by filename order after b.cfg, in which (c.cfg) I could have two pieces, the first to add %J = #$@F[g]/h$ via @Part , the second to check the part for the desired value of #j via @PART[the list just used]:HAS[#j[h]] and do stuff if it passes the check? Are you absolutely certain that this is not valid: Spoiler PART { name = something //some stuff MODULE:NEEDS[KIS] { //some other stuff } MODULE { name = even more stuff } } ? Edited October 19, 2018 by Apaseall Quote Link to comment Share on other sites More sharing options...
blowfish Posted October 20, 2018 Share Posted October 20, 2018 2 hours ago, Apaseall said: Hmm. So if for example I had b.cfg as a part definition file, which is .cfg, then I would do things in this order: Reveal hidden contents 1. Let the part def file run. i.e. b.cfg. 2. Have file (c.cfg) named such that it executes by filename order after b.cfg, in which (c.cfg) I could have two pieces, the first to add %J = #$@F[g]/h$ via @Part , the second to check the part for the desired value of #j via @PART[the list just used]:HAS[#j[h]] and do stuff if it passes the check? Are you absolutely certain that this is not valid: Hide contents PART { name = something //some stuff MODULE:NEEDS[KIS] { //some other stuff } MODULE { name = even more stuff } } ? :NEEDS is the exception I forgot to mention. No other MM features work in root non-patch nodes The order only matters between patches. Non-patch nodes are all added at the same time before any patches are run (or rather, everything is added to the same place and then MM extracts patches and then applies them in order) Quote Link to comment Share on other sites More sharing options...
Apaseall Posted October 20, 2018 Share Posted October 20, 2018 12 hours ago, blowfish said: :NEEDS is the exception I forgot to mention. No other MM features work in root non-patch nodes The order only matters between patches. Non-patch nodes are all added at the same time before any patches are run (or rather, everything is added to the same place and then MM extracts patches and then applies them in order) Cheers thanks for clearing that one up for me. Simple order then 1 create non-patch node, 2 MM extracts and processes patches. No need to bother with name selection to provide process ordering until we come to MM patch processing. Cool. Thanks for your help. Quote Link to comment Share on other sites More sharing options...
Atlessa Posted October 20, 2018 Share Posted October 20, 2018 Hey guys, I need a little help with my syntax for a little patch I wrote.. The goal was to improve performance on my little old potato by reducing part count by not having to spam solar panels en mass... What I have currently: @PART[*]:has[@RESOURCE[ElectricCharge]]:Final { MODULE { name = ModuleGenerator isAlwaysActive = true OUTPUT_RESOURCE { name = ElectricCharge rate = 0.1 } } } This WORKS but I would like to change it so that the actual generation is dependent on the parts amount of EC stored. So something like [rate = (ElectricCharge*0.002)]. But I don't know the syntax for that, and booting the game up for testing takes 15 minutes each time... (told you it's a potato) so experimenting is not exactly the best option for me currently. Quote Link to comment Share on other sites More sharing options...
Nightside Posted October 20, 2018 Share Posted October 20, 2018 @Atlessa do you want to use the capacity of your battery to determine rate? You can use that as a variable, there is an example of using variables a few posts back. Or are you trying to use the current amount of EC to change the rate of production dynamically? I don’t think that would be possible with MM. Quote Link to comment Share on other sites More sharing options...
Atlessa Posted October 20, 2018 Share Posted October 20, 2018 Yes. Capacity of course. I know MM only does it's thing once, on startup. Quote Link to comment Share on other sites More sharing options...
Apaseall Posted October 20, 2018 Share Posted October 20, 2018 1 hour ago, Atlessa said: Yes. Capacity of course. I know MM only does it's thing once, on startup. The syntax would be something like: Spoiler %Multiplier = 2 @ResourceAmount *= #$Multiplier$ !Multiplier = delete You would need to create the variable in the right place and make sure that you delete it from there also. Also ResourceAmount is not the name you would be changing. What I would do is examine an example part. Locate the Module that contains the value you want to change. Of course this may not be named Module but something like Resource. Then in your code you would drill down to where that value is, put the multiplier just before it, do the multiplication then delete the variable. Here is an example: Spoiler @PART[PAL_Claw]:NEEDS[KONSTRUCTION&KIS]:AFTER[KONSTRUCTION] { ModuleKISPickup { %MYMMKISRanMul = 1.5 // create variable my_mm KIS Range Multiplier 1.0 = same as stock KONSTRUCTION @maxDistance *= #$MYMMKISRanMul$ // @grabMaxMass *= #$MYMMKISRanMul$ } } @PART[PAL_Claw|PAL_Magnet|PAL_Gripper|PAL_Crane|PAL_Forklift]:NEEDS[KONSTRUCTION]:FINAL { ModuleKISPickup { !MYMMKISRanMul = delete // delete variable } } Although I only included the one part named PAL_Claw, because in reality I made changes to PAL_Claw or PAL_Magnet or PAL_Gripper or PAL_Crane or PAL_Forklift I chose to delete the variable once, rather than inside each part. Hope this helps. Quote Link to comment Share on other sites More sharing options...
Atlessa Posted October 20, 2018 Share Posted October 20, 2018 (edited) Edit: I've figured it out, mostly. I just need to get MM to set my variable to the Electric Charge of the module being edited. So far I've got %ATMMABC = 1 @$ATMMABC$ *= [[RESOURCE]ElectricCharge]] But that won't do it. I tried different variations of the syntax but just can't figure it out Below this line is my original post which is now mostly redundant. I've left it in for clarity. ----------------------------------------------- Thanks for that. I think you misunderstood what I want to do, though... (Or you just gave an example... works for me) So here's what I think I need to do, pseudo code first: Spoiler %ABC = 1 /create variable ABC and set it to 1 @ABC = [ElectricCharge] /Set ABC to the amount of electric charge capacity the current part has @ABC *= 0.01 /set ABC to 1% of the above /and then MODULE { name = ModuleGenerator isAlwaysActive = true OUTPUT_RESOURCE { name = ElectricCharge rate = ABC } } To create a NEW module on the part that generates ABC electric charge per second I got that much... now I just need to figure out the correct syntax, and I have no clue where to look. The posts above are WAY more complex than this and don't help me at all. Edit: So I tried Spoiler @PART[*]:has[@RESOURCE[ElectricCharge]]:Final { MODULE { %ATMMABC = ElectricCharge %ATMMABC *= 0.01 name = ModuleGenerator isAlwaysActive = true OUTPUT_RESOURCE { name = ElectricCharge rate = #$ATMMABC$ } !ATMMABC = delete } } And that didn't work. Edit: Checked the logs, found this; [ERR 20:51:22.715] [ModuleManager] Error - Cannot parse variable search when inserting new key rate = #$ATMMABC$ So I'm guessing I can't set up a new generator with a variable rate? Edited October 20, 2018 by Atlessa Quote Link to comment Share on other sites More sharing options...
Atlessa Posted October 21, 2018 Share Posted October 21, 2018 Anyone? I'm really at my wits end... Is what I'm trying to do even possible with MM? Quote Link to comment Share on other sites More sharing options...
linuxgurugamer Posted October 21, 2018 Share Posted October 21, 2018 1 hour ago, Atlessa said: Anyone? I'm really at my wits end... Is what I'm trying to do even possible with MM? People do have a life outside KSP. Sometimes it may take a day or so to get an answer. Be patient, and keep in mind that people wont post if they dont have an answer Quote Link to comment Share on other sites More sharing options...
Apaseall Posted October 21, 2018 Share Posted October 21, 2018 3 hours ago, Atlessa said: Anyone? I'm really at my wits end... Is what I'm trying to do even possible with MM? Or in my case, a little sleep Please read my example again, pay attention to @. Without some of those you ain't going to be modifying something that exists. etc. You know to look inside modulemanager.configcache to check the results of any patches right? Quote Link to comment Share on other sites More sharing options...
blowfish Posted October 21, 2018 Share Posted October 21, 2018 (edited) @Atlessa The way you have it it will interpret that the literal string "ElectricCharge" - ModuleManager has no knowledge of what a RESOURCE { } node is or what its amount/maxAmount mean, or that ElectricCharge is the name of some particular resource. I encourage you to find examples in other mods in the future for your own learning but I'll give this one to you Spoiler @PART[*]:has[@RESOURCE[ElectricCharge]]:Final { MODULE { name = ModuleGenerator isAlwaysActive = true OUTPUT_RESOURCE { name = ElectricCharge rate = #$/RESOURCE[ElectricCharge]/maxAmount$ @rate *= 0.01 } } } Let's dissect this a bit # - tells ModuleManager that you're going to be using variables in the value $...$ - tells you that the thing between the $ signs is a variable /RESOURCE[ElectricCharge]/maxAmount The leading / tells it to look in the root node that you're currently patching (in this case, some PART { }) RESOURCE[ElectricCharge] looks for a RESOURCE { } node with name = ElectricCharge maxAmount tells it to find the value called maxAmount in that node ../../RESOURCE[ElectricCharge]/maxAmount would also work here (tells it to go up two levels and then look for the node) Just as a note, the !ATMMABC = delete you had wouldn't work the way you want because all values are processed before all nodes (artifact of how KSP stores things). You'd be removing the value before using it Edited October 21, 2018 by blowfish Quote Link to comment Share on other sites More sharing options...
Apaseall Posted October 21, 2018 Share Posted October 21, 2018 6 minutes ago, blowfish said: @Apaseall The way you have it it will interpret that the literal string "ElectricCharge" - ModuleManager has no knowledge of what a RESOURCE { } node is or what its amount/maxAmount mean, or that ElectricCharge is the name of some particular resource. I encourage you to find examples in other mods in the future for your own learning but I'll give this one to you. Erm. I think you might have who wrote what a bit mixed up. My example was merely to show how to make a variable, how to use it as a multiplier and delete it. I did advise examining example parts to determine in which nodes the pieces you wanted to amend are located. Quote Link to comment Share on other sites More sharing options...
blowfish Posted October 21, 2018 Share Posted October 21, 2018 5 minutes ago, Apaseall said: Erm. I think you might have who wrote what a bit mixed up. My example was merely to show how to make a variable, how to use it as a multiplier and delete it. I did advise examining example parts to determine in which nodes the pieces you wanted to amend are located. Oops, @ed the wrong person. Fixing... Quote Link to comment Share on other sites More sharing options...
Atlessa Posted October 21, 2018 Share Posted October 21, 2018 Spoiler 10 hours ago, blowfish said: @Atlessa The way you have it it will interpret that the literal string "ElectricCharge" - ModuleManager has no knowledge of what a RESOURCE { } node is or what its amount/maxAmount mean, or that ElectricCharge is the name of some particular resource. I encourage you to find examples in other mods in the future for your own learning but I'll give this one to you Hide contents @PART[*]:has[@RESOURCE[ElectricCharge]]:Final { MODULE { name = ModuleGenerator isAlwaysActive = true OUTPUT_RESOURCE { name = ElectricCharge rate = #$/RESOURCE[ElectricCharge]/maxAmount$ @rate *= 0.01 } } } Let's dissect this a bit # - tells ModuleManager that you're going to be using variables in the value $...$ - tells you that the thing between the $ signs is a variable /RESOURCE[ElectricCharge]/maxAmount The leading / tells it to look in the root node that you're currently patching (in this case, some PART { }) RESOURCE[ElectricCharge] looks for a RESOURCE { } node with name = ElectricCharge maxAmount tells it to find the value called maxAmount in that node ../../RESOURCE[ElectricCharge]/maxAmount would also work here (tells it to go up two levels and then look for the node) Just as a note, the !ATMMABC = delete you had wouldn't work the way you want because all values are processed before all nodes (artifact of how KSP stores things). You'd be removing the value before using it Thanks... I would have NEVER figured that out. Heck, even looking at it, I don't understand why I would need the #$...$ for the electric charge, let alone where I should have found the /maxAmount Quote Link to comment Share on other sites More sharing options...
blowfish Posted October 21, 2018 Share Posted October 21, 2018 14 minutes ago, Atlessa said: Hide contents Thanks... I would have NEVER figured that out. Heck, even looking at it, I don't understand why I would need the #$...$ for the electric charge, let alone where I should have found the /maxAmount Did my explanation make sense? I can go into a bit more depth if any of the parts are confusing. Quote Link to comment Share on other sites More sharing options...
Atlessa Posted October 21, 2018 Share Posted October 21, 2018 11 minutes ago, blowfish said: Did my explanation make sense? I can go into a bit more depth if any of the parts are confusing. Sort of. I think. At least to the point that I realize; I'm too old to learn this sh... this stuff. And will probably have to rely on others to write awesome mods that make my life around Kerbol easier for me and more managable for my little potato. Fly safe. Quote Link to comment Share on other sites More sharing options...
Apaseall Posted October 22, 2018 Share Posted October 22, 2018 Hi everyone, got a new question: Spoiler If I look at myPart in ModuleManager.ConfigCache I can see this, PART { name = myPart MODULE { name = A B = C;D;E } } Would this test to see if D is not one of the items in B and add it? @PART[myPart]:HAS[MODULE[A]]:FINAL { @MODULE[A]:HAS[!#B[D]] { @B ^=:$:;D } } I would replace :FINAL with a suitable :AFTER[] Quote Link to comment Share on other sites More sharing options...
blowfish Posted October 22, 2018 Share Posted October 22, 2018 14 minutes ago, Apaseall said: Hi everyone, got a new question: Hide contents If I look at myPart in ModuleManager.ConfigCache I can see this, PART { name = myPart MODULE { name = A B = C;D;E } } Would this test to see if D is not one of the items in B and add it? @PART[myPart]:HAS[MODULE[A]]:FINAL { @MODULE[A]:HAS[!#B[D]] { @B ^=:$:;D } } I would replace :FINAL with a suitable :AFTER[] I think you want @MODULE[A]:HAS[~B[*D*]] ~ means "does not have value" *D* means match anything containing D. If you just had D it would only match if the value was D with nothing before or after it Quote Link to comment Share on other sites More sharing options...
Starwaster Posted October 22, 2018 Share Posted October 22, 2018 1 hour ago, Apaseall said: I would replace :FINAL with a suitable :AFTER[] Only if he's putting it in a mod. 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.