Jump to content

[1.8.x-1.12.x] Module Manager 4.2.3 (July 03th 2023) - Fireworks season


sarbian

Recommended Posts

3 minutes ago, MatterBeam said:

Hi!

I'm trying to modify the multiple ModuleResourceConverter sections of the ISRU part. However, all I know is using @MODULE[ModuleResourceConverter]. How do I write an MM config that targets the 'ConverterName =' line afterwards?  

I'm not sure this is what you want to do:

@PART
{
	@MODULE[ModuleResourceConverter]:HAS[#ConverterName[namehere]]
	{
		// your changes here
	}
}

this will target only the MODULE which have

name = ModuleResourceConverter

AND

ConverterName = namehere

Link to comment
Share on other sites

What's the proper syntax to filter for a part that has "A" OR "B"? I can find examples of AND, but not OR.

I'm looking for how to do this:

@PART[*]:HAS[@PLUME[firstthing] OR IT HAS[@PLUME[secondthing]] one or the other, not both

{}

Edited by Rhedd
Link to comment
Share on other sites

 

11 minutes ago, Rhedd said:

What's the proper syntax to filter for a part that has "A" OR "B"? I can find examples of AND, but not OR.

I'm looking for how to do this:

@PART[*]:HAS[@PLUME[firstthing] OR IT HAS[@PLUME[secondthing]] one or the other, not both

{}

You could do it by setting a value in one patch and then checking it in another

@PART[*]:HAS[@PLUME[firstPlume],@PLUME[secondPlume]]
{
	%somethingDescriptive = someValue
}

@PART[*]:HAS[@PLUME[firstPlume]|@PLUME[secondPlume]&#somethingDescriptive[someValue]]
{
	// stuff you want to do
}

I'm pretty sure the order of operations on that is correct there.  Maybe someone has a more efficient way to do it.  You might also want to remove the value in another patch, since it'll generate a log warning otherwise (I think).

Edited by blowfish
Link to comment
Share on other sites

1 hour ago, blowfish said:

 

You could do it by setting a value in one patch and then checking it in another


@PART[*]:HAS[@PLUME[firstPlume],@PLUME[secondPlume]]
{
	%somethingDescriptive = someValue
}

@PART[*]:HAS[@PLUME[firstPlume]|@PLUME[secondPlume]&#somethingDescriptive[someValue]]
{
	// stuff you want to do
}

I'm pretty sure the order of operations on that is correct there.  Maybe someone has a more efficient way to do it.  You might also want to remove the value in another patch, since it'll generate a log warning otherwise (I think).

Clever solution, but it won't really work, because although I gave a two-part example, what I really want to do is apply the same long bunch of code to a whole LIST of things without having to write it all out for every one of them.

I take it your response means that there isn't a simple OR syntax for this? I'm really surprised, it seems so obvious.

Link to comment
Share on other sites

3 hours ago, Rhedd said:

I take it your response means that there isn't a simple OR syntax for this? I'm really surprised, it seems so obvious.

Not quite.  Module Manager scripts have operators for Logical AND (',' or '&'), that is, both A and B and only that.

They have an operator for Logical OR, or more specifically a Logical Inclusive OR ('|'), that is only A, only B, or both A and B.

But as far as I know, MM syntax doesn't yet have a Logical XOR, Exclusive XOR, A XOR B, just one of A or B, not both.  Which is what you want, @Rhedd.

4 hours ago, Rhedd said:

I'm looking for how to do this:

@PART[*]:HAS[@PLUME[firstthing] OR IT HAS[@PLUME[secondthing]] one or the other, not both

{}

You can write a script that will act as an XOR operation and in not too much space.

This will definitely work.  I don't think current Module Manager syntax allows a simpler script that will do the same as this.

@PART[*]:HAS[@PLUME[firstthing],!PLUME[secondthing]]
{
	// whatever needs to be done 1st copy
}

@PART[*]:HAS[!PLUME[firstthing],@PLUME[secondthing]]
{
	// whatever needs to be done 2nd copy
}

The advantage of the script above is if those two "whatever needs to be done" sections actually have to be a little bit different, it's very easy to make them so.

But Rhedd, you said "whatever needs to be done" was the same for both cases.  You still need to use this syntax, as I think there is no other more compact way in MM scripting to do so.

@sarbianis likely well aware of this, as XOR is a common computer concept, and he'll know how he could introduce it.  But it can be very complex to do.  And XOR isn't commonly needed for the sort of stuff that MM scripts do.  I search this whole topic and haven't found any mention in 2.5 years of Exclusive OR or XOR prior to this.

EDIT: From the Modular Manager Syntax wiki entry:

Quote

You can use & for AND, | for OR and ! for NOT in the needs listing. To allow backwards compatibility , is treated as an alias for & (AND). If you combine several | and &, eg NEEDS[Mod1|Mod2&!Mod3|Mod4] this is treated as ( Mod1 OR Mod2 ) AND ( ( NOT Mod3 ) OR Mod4 ). I won't be implementing brackets, it would make the parser far too complicated. There's always a way to represent what you want in this form, although it might need a few repeated terms, but I'm not sure I can truly see much of a use case for anything super complex.

Now that I think of it after reading this, there are better ways to do XOR, but it appears @Rhedd only needs standard Inclusive OR....

Edited by Jacke
Link to comment
Share on other sites

2 hours ago, Jacke said:

Not quite.  Module Manager scripts have operators for Logical AND (',' or '&'), that is, both A and B and only that.

They have an operator for Logical OR, or more specifically a Logical Inclusive OR ('|'), that is only A, only B, or both A and B.

But as far as I know, MM syntax doesn't yet have a Logical XOR, Exclusive XOR, A XOR B, just one of A or B, not both.  Which is what you want, @Rhedd.

You can write a script that will act as an XOR operation and in not too much space.

This will definitely work.  I don't think current Module Manager syntax allows a simpler script that will do the same as this.


@PART[*]:HAS[@PLUME[firstthing],!PLUME[secondthing]]
{
	// whatever needs to be done 1st copy
}

@PART[*]:HAS[!PLUME[firstthing],@PLUME[secondthing]]
{
	// whatever needs to be done 2nd copy
}

The advantage of the script above is if those two "whatever needs to be done" sections actually have to be a little bit different, it's very easy to make them so.

But Rhedd, you said "whatever needs to be done" was the same for both cases.  You still need to use this syntax, as I think there is no other more compact way in MM scripting to do so.

@sarbianis likely well aware of this, as XOR is a common computer concept, and he'll know how he could introduce it.  But it can be very complex to do.  And XOR isn't commonly needed for the sort of stuff that MM scripts do.  I search this whole topic and haven't found any mention in 2.5 years of Exclusive OR or XOR prior to this.

I actually made it sound more complicated than I need it to be! Your information is great, Jacke, and thanks for taking the time to explain it. I'm sorry I didn't make the problem clear and save you some typing. :blush:

A plain old inclusive OR is fine for what I want, since there will never be a time that the part has more than one of the choices, and it wouldn't hurt anything if it did!

I've tried | , because I saw it used in a different context, but I couldn't get it to work so I assumed it didn't in this case. Sorry for being dense, but where exactly where would I put the |  ?

So what I believe I tried was...

@PART[*]:HAS[@PLUME[firstthing] | PLUME[secondthing]]

The first thing worked, but the second didn't, if I'm remembering correctly. (I've tried too many things to remember, now!:P)

Edited by Rhedd
Link to comment
Share on other sites

OH NOW I GET IT!!!  What @blowfish was trying to do.

But after reading the wiki pages, I believe there's a better way to do XOR.

But @Rhedd just needs an Inclusive OR.

28 minutes ago, Rhedd said:

A plain old inclusive OR is fine for what I want, since there will never be a time that the part has more than one of the choices, and it wouldn't hurt anything if it did! ....

So what I believe I tried was...


@PART[*]:HAS[@PLUME[firstthing] | PLUME[secondthing]]

The first thing worked, but the second didn't, if I'm remembering correctly. (I've tried too many things to remember, now!:P)

This is what you want, Rhedd.

@PART[*]:HAS[@PLUME[firstPlume]|@PLUME[secondPlume]]
{
	// long script of what you want to do to those parts
}

You missed the second '@'. :)

Now if Exclusive OR, XOR, was needed....

From the Module Manager Syntax wiki page, OR ('|') binds tighter than AND (',' or '&').  And with the Module Manager Handbook wiki page implies that NOT (using '!' in place of '@') binds tightest of all.  So....

Assuming what I've read applies to HAS blocks, including some things that only referred to NEEDS:....

// parts must have firstthing XOR secondthing
// OR binds tighter than AND, but NOT binds tightest of all
// thus (firstthing OR secondthing) AND ((NOT firstthing) OR (NOT secondthing))
@PART[*]:HAS[@PLUME[firstthing]|@PLUME[secondthing]&!PLUME[firstthing]|!PLUME[secondthing]]
{
	// long script of what you want to do to those parts
}

Someone with better knowledge of MM syntax want to confirm this?

Edited by Jacke
Link to comment
Share on other sites

@Jacke, I would've thought that the missing @ was a mistake in my post, not in what I did earlier, but it wasn't working, so I tried it.

I've now tried everything I could think of, carefully documenting each try, and here are the results: (Note the two things I'm testing for are very similar in name- "Kerolox-Lower-F1" and "Kerolox-Lower".)

@PART[*]:HAS[@PLUME[Kerolox-Lower-F1]]:FINAL ............. WORKS

@PART[*]:HAS[@PLUME[Kerolox-Lower]]:FINAL ............. WORKS

@PART[*]:HAS[@PLUME[Kerolox-Lower-F1] | @PLUME[Kerolox-Lower]]:FINAL ............. NOTHING WORKS

@PART[*]:HAS[@PLUME[Kerolox-Lower-F1]|@PLUME[Kerolox-Lower]]:FINAL ............. FIRST CASE WORKS, SECOND DOES NOT

So now I'm totally lost. But hey, I learned one thing I didn't know before! MM seems to care about spaces. >_>

Link to comment
Share on other sites

24 minutes ago, sarbian said:

There is no OR. OR means handling operator priorities so no thanks.

Indeed.   As someone's who's coded priority operators (and may they all be suffix operators...) I completely understand.

Starting to get the hang of the syntax.  Wish I had better documentation (many of my old MM topic links from the old forum software I couldn't find the post and post numbers didn't auto-translate).  Of course, I could always go diving in the source.  Where it likely uses standard library calls.

But I think I have a solution....

2 hours ago, Rhedd said:

 


@PART[*]:HAS[@PLUME[Kerolox-Lower-F1]|@PLUME[Kerolox-Lower]]:FINAL ............. FIRST CASE WORKS, SECOND DOES NOT

So now I'm totally lost. But hey, I learned one thing I didn't know before! MM seems to care about spaces. >_>

Keep spaces out of scripts except for indentation, values, and comments.

And where the '|' is above, only ',' is allowed, AND.

So try this (may work).

@PART[*]:HAS[@PLUME[Kerolox-Lower|Kerolox-Lower-F1]]:FINAL
{
	// changes go here
}

And if that doesn't work, and the only possibilities of PLUME names that start with "Kerolox-Lower" are those 2 and only those 2, try this.

@PART[*]:HAS[@PLUME[Kerolox-Lower*]]:FINAL
{
	// changes go here
}

 

Edited by Jacke
Link to comment
Share on other sites

37 minutes ago, Cerberus738 said:

SO just a heads up. Module manager does not initialize with 1.1.2. No patches get applied at the loading screen.

Anyone else having this problem?

Is there something i overlooked?

Yes, I see it, too.  There's now an exception when MM tries to start:

[EXC 07:20:31.521] MissingMethodException: Method not found: 'PopupDialog.SpawnPopupDialog'.
	ModuleManager.ModuleManager.Awake ()
	UnityEngine.GameObject:AddComponent(Type)
	AddonLoader:StartAddon(LoadedAssembly, Type, KSPAddon, Startup)
	AddonLoader:StartAddons(Startup)
	<LoadObjects>c__Iterator32:MoveNext()
	UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
	<CreateDatabase>c__Iterator31:MoveNext()
	UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
	GameDatabase:StartLoad()
	<LoadSystems>c__Iterator45:MoveNext()
	UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
	LoadingScreen:Start()

Yay for breaking under-the-hood changes... =P

Link to comment
Share on other sites

2 minutes ago, legoclone09 said:

A whole TWO hours and 15 minutes? Too slow!

Just kidding, great job with getting it out fast!

Yeah, sorry about that I was out getting food :wink:

Link to comment
Share on other sites

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...