Jump to content

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


sarbian

Recommended Posts

It is loading, but I'm curious why that would matter? Does the added module have to have an associated PartModule assembly?

If so, and wanted to add a Module without an associated .dll, could I do so by using a :FINAL tag?

Hmm.. off to test..

- - - Updated - - -

Regardless of my above curiosity, the following does not work:


@PART
[*]:HAS[@MODULE[ModuleDockingNode]]
{
@MODULE[ModuleDockingNode],*
{
%portName_DPAI = default
%portName_DPAI_initialized = false
}
}

- - - Updated - - -


Applying node NavyFish/Plugins/moduleDockingNodeNamed/@PART
[*]:HAS[@MODULE[ModuleDockingNode]] to Squad/Parts/Utility/dockingPort/dockingPort/dockingPort2
[LOG 23:49:39.978] [ModuleManager] Applying node NavyFish/Plugins/moduleDockingNodeNamed/@PART
[*]:HAS[@MODULE[ModuleDockingNode]] to Squad/Parts/Utility/dockingPortInline/dockingPortInline/dockingPortLateral
[LOG 23:49:39.979] [ModuleManager] Applying node NavyFish/Plugins/moduleDockingNodeNamed/@PART
[*]:HAS[@MODULE[ModuleDockingNode]] to Squad/Parts/Utility/dockingPortJr/dockingPortJr/dockingPort3

The patch is being applied and the "ModuleDockingNode" is stock... Yet no changes to the persistence or quicksave files for existing craft or newly created craft. wha...

It'll add it to the part's config node but if there's no actual PartModule then I don't see how it's going to be added to any parts/vessels in the save file. There's nothing to actually SAVE it or load it.

Link to comment
Share on other sites

Oh, then I know the issue.

Replace your "&" with ","

In 2.5.7 this was changed for fixing the science reports containing a "&"

I'm afraid that I cheered too soon when replace "&" by "," the following code still generates 4 errors when loading KSP


//Specific part fixes
@PART[FNMethaneTank*]:HAS[@RESOURCE[LqdMethane],@RESOURCE[Oxidizer],!MODULE[ModuleFuelTanks]]:NEEDS[WarpPlugin]:FOR[RealFuels]
{
MODULE
{
name = ModuleFuelTanks
temp = 0
volume = 0
type = Cryogenic
@temp = #$../RESOURCE[LqdMethane]/maxAmount$
@temp *= 4.412
@volume = #$../MODULE[ModuleFuelTanks]/temp$
@temp = #$../RESOURCE[Oxidizer]/maxAmount$
@temp *= 5
@volume += #$../MODULE[ModuleFuelTanks]/temp$
!temp = 0
}
!RESOURCE[LqdMethane] {}
!RESOURCE[Oxidizer] {}
}

To repeat, the above MM code worked in ModuleManager.2.5.6, but no longer in MM 2.5.8 and MM 2.5.9 (I don't know about MM 2.5.7). So something must have changed which makes this script fail! Notice that if I remove both occurances of "@volume", I don't get any error (but also no functionality).

Both are similar in the way how they attempt to access the "temp" parameter.


@volume = #$../MODULE[ModuleFuelTanks]/temp$
@volume += #$../MODULE[ModuleFuelTanks]/temp$

perhaps it can't find the temporary "temp" variable after it was created on the second line? it almost looks like a list wasn't updated...

Edited by FreeThinker
Link to comment
Share on other sites

I'm afraid that I cheered too soon when replace "&" by "," the following code still generates 4 errors when loading KSP


//Specific part fixes
@PART[FNMethaneTank*]:HAS[@RESOURCE[LqdMethane],@RESOURCE[Oxidizer],!MODULE[ModuleFuelTanks]]:NEEDS[WarpPlugin]:FOR[RealFuels]
{
MODULE
{
name = ModuleFuelTanks
temp = 0
volume = 0
type = Cryogenic
@temp = #$../RESOURCE[LqdMethane]/maxAmount$
@temp *= 4.412
@volume = #$../MODULE[ModuleFuelTanks]/temp$
@temp = #$../RESOURCE[Oxidizer]/maxAmount$
@temp *= 5
@volume += #$../MODULE[ModuleFuelTanks]/temp$
!temp = 0
}
!RESOURCE[LqdMethane] {}
!RESOURCE[Oxidizer] {}
}

To repeat, the above MM code worked in ModuleManager.2.5.6, but no longer in MM 2.5.8 and MM 2.5.9 (I don't know about MM 2.5.7). So something must have changed which makes this script fail! Notice that if I remove both occurances of "@volume", I don't get any error (but also no functionality).

Both are similar in the way how they attempt to access the "temp" parameter.


@volume = #$../MODULE[ModuleFuelTanks]/temp$
@volume += #$../MODULE[ModuleFuelTanks]/temp$

perhaps it can't find the temporary "temp" variable after it was created on the second line? it almost looks like a list wasn't updated...

As I said earlier:

I don't know why you would need to go into the above node to go back into the node you already are.

That`s why I would replace

#$../MODULE[ModuleFuelTanks]/temp$

with

#$temp$

That's just the way it works in this example:

http://forum.kerbalspaceprogram.com/threads/55219-Module-Manager-2-3-5-%28Sept-14%29-Loading-Speed-Fix?p=1416253&viewfull=1#post1416253

(from https://github.com/sarbian/ModuleManager/wiki/Module%20Manager%20Syntax)

to be safe you could also use

%temp = 0

when you first define it.

Link to comment
Share on other sites

To repeat, the above MM code worked in ModuleManager.2.5.6, but no longer in MM 2.5.8 and MM 2.5.9 (I don't know about MM 2.5.7). So something must have changed which makes this script fail! Notice that if I remove both occurances of "@volume", I don't get any error (but also no functionality).

Can you please test with 2.5.7 ? I don't see what changed in the code that could impact variable if you test 2.5.7 i'll be sure it's the regex change.

And post a log.

Edited by sarbian
Link to comment
Share on other sites

Alright, I tested and 2.5.7 also has the same problen

- - - Updated - - -

As I said earlier:

I don't know why you would need to go into the above node to go back into the node you already are.

That`s why I would replace

#$../MODULE[ModuleFuelTanks]/temp$

with

#$temp$

Well at least modification no longer generates 4 errors and it also appears to work as intended.

Link to comment
Share on other sites

MM can add values to a module but if the module itself does know of those values they won't be in the saves.

Thank you. That explains everything :)

- - - Updated - - -

Is there a way to determine the index of the module you're currently 'inspecting'? i.e.:


@PART[*]:HAS[@MODULE[ModuleDockingNode], @MODULE[ModuleDockingNodeNamed]]
{
@MODULE[ModuleDockingNodeNamed],*
{
%controlTransformName = #$../MODULE,[B]X[/B][ModuleDockingNode]/controlTransformName
}
}

Where X is the index of the ModuleDockingNodeNamed.

In pseudocode, the above snippet should:


For each part that has both a ModuleDockingNode and ModuleDockingNodeNamed
At each ModuleDockingNodeNamed (index [B]X[/B])
add or edit the field "controlTransformName" so its value matches the "controlTransformName" from the ModuleDockingNode of corresponding index [B]X[/B] in the same part.

- - - Updated - - -

For that matter, here's another question: Can you add modules 'outside' of the currently iterated module?

Pseudocode:


For each part that has a ModuleDockingNode
At each ModuleDockingNode
add a new module immediately after this node (outside of this node)

so a part with N number of ModuleDockingNodes would end up having N entirely new modules added to it (in the part's root)

- - - Updated - - -

For that matter, here's another question: Can you add modules 'outside' of the currently iterated module?

Nevermind that last question - yes, you can, by 'copying' nodes and then changing their names (your example was helpful)

Link to comment
Share on other sites

I am unaware of such. However, you can do

@MODULE[foo],0 // the first

@MODULE[foo],1 // the second

and so forth

(same with @NODE,0 and @key,0 btw)

Thanks. I'd originally hardcoded it like that out to something like 16 modules, but it just felt too clunky. Ended up using a plugin to index into the modules. cuz MOAR codes is the kerbal way.

@sarbian - It might be useful for others to have access to the index, i.e.


@MODULE[foo],*
{
%index = #$GLOBALVARS/currentIndex$
}

The above snippet would add/edit the index key to have the value of 'this' foo module's index. Whether that index is based upon all of the part's modules, or just modules of type [foo] (or whatever was searched for, filtered, etc), is up to you (the latter is more useful, IMO, but the former likely more flexible). Just a thought!

------------------------------------------------------------------------------------

In case it's of interest to anyone (doubtful), or may be helpful (possible), I'm posting my commented solution below. The goal here was to add one new module (ModuleDockingNodeNamed) for every ModuleDockingNode in a part. This is two patches in-one - the first patch cleans up existing ModuleDockingNodeNamed modules, which would only take effect if the user had a previous version of DPAI installed - the second patch is simpler and only works on 'fresh' modules (those untainted by the nasty older deprecated stuff).


//First find all of the old ModuleDockingNodeNamed modules (they won't have a controlTransformName key)
@PART[*]:HAS[@MODULE[ModuleDockingNode],@MODULE[ModuleDockingNodeNamed]:HAS[~controlTransformName[]]]
{
//Change the module type on the old ModuleDockingNodeNamed module so it's out of the way but the data is saved for later restoration
//Prior to this patch, there would only ever be one ModuleDockingNodeNamed in a part.
@MODULE[ModuleDockingNodeNamed]:HAS[~controlTransformName[]]
{
@name = ModuleDockingNodeNamed_deprecated
}

//Now copy each ModuleDockingNode, then strip its contents, change its name to ModuleDockingNodeNamed, and give it default values
+MODULE[ModuleDockingNode],*
{
//remove all keys
-* = dummy

//remove all EVENTS and ACTIONS nodes
-EVENTS,* {}
-ACTIONS,* {}

//change the name key (hence 'type' of module)
%name = ModuleDockingNodeNamed
%controlTransformName = not_initialized
%portName = default
%initialized = false
}

//Go to the first of these new ModuleDockingNodeNamed modules, and restore in the data we saved earlier
@MODULE[ModuleDockingNodeNamed],0
{
@portName = #$../MODULE[ModuleDockingNodeNamed_deprecated]/portName$
@initialized = #$../MODULE[ModuleDockingNodeNamed_deprecated]/initialized$
}

//Finally, delete the deprecated module
-MODULE[ModuleDockingNodeNamed_deprecated]
}

//Next, repeat this process for all new parts which don't already have a ModuleDockingNodeNamed (no need to save/restore anything this time)

//So find all parts that have a ModuleDockingNode with no ModuleDockingNodeNamed modules
@PART[*]:HAS[@MODULE[ModuleDockingNode],!MODULE[ModuleDockingNodeNamed]]
{
//As before, copy each ModuleDockingNode, then strip its contents, change its name to ModuleDockingNodeNamed, and give it default values
+MODULE[ModuleDockingNode],*
{
-* = dummy
-EVENTS,* {}
-ACTIONS,* {}
%name = ModuleDockingNodeNamed
%controlTransformName = not_initialized
%portName = default
%initialized = false
}
}

Edited by NavyFish
code formatz
Link to comment
Share on other sites

Some massive issues with 2.5.9

1. Lots and LOTS and i mean LOTS! of MM configs stopped working

2. Tweakscaled parts in VAB go wacko , like 5 meter tanks grow into 15 meter tanks!

3. Really new and strange behaviors in scene changing

4. Ive went back to the older version 2.5.6 and everything worked again

5. Will wait for 2.5.10 for a proper fix

Link to comment
Share on other sites

Some massive issues with 2.5.9

1. Lots and LOTS and i mean LOTS! of MM configs stopped working

2. Tweakscaled parts in VAB go wacko , like 5 meter tanks grow into 15 meter tanks!

3. Really new and strange behaviors in scene changing

4. Ive went back to the older version 2.5.6 and everything worked again

5. Will wait for 2.5.10 for a proper fix

1. Since 2.5.7 the "&" is a valid char for key values and no syntax anymore. This was so that science reports containing a "&" could work when MM was installed. This can be fixed to change a "&" by a ","

2. That is a TweakScale bug, no MM.

3. Like what?

4. See 1.

5. See 1. and 2.

Link to comment
Share on other sites

suggestion, allow numbered-value keys to accept value of other keys, ie

@PART

{

CrewCapacity = 5

MODULE

{

ResourceAmount = CrewCapacity * 5 <- this

}

}

currently i'm making 40 patches, for 1 2 3 4 ... 40 crew, when the above could simplify it into 1 patch :)

Link to comment
Share on other sites

suggestion, allow numbered-value keys to accept value of other keys, ie

@PART

{

CrewCapacity = 5

MODULE

{

ResourceAmount = CrewCapacity * 5 <- this

}

}

currently i'm making 40 patches, for 1 2 3 4 ... 40 crew, when the above could simplify it into 1 patch :)

You can already do what you want with variables in MM patches: http://forum.kerbalspaceprogram.com/threads/55219-Module-Manager-2-3-5-%28Sept-14%29-Loading-Speed-Fix?p=1416253&viewfull=1#post1416253

Here's an example of a config I made for Ioncross Crew Support to replace a lot of HAS[#crew[1]], HAS[#crew[2]], etc etc until I got tired of typing.


IONCROSS_MM_SETTINGS
{
O2 = 850
CO2 = 200
}


@PART
[*]:HAS[#CrewCapacity
[*],~CrewCapacity[0],!MODULE[IonModuleCrewSupport]]:FOR[IoncrossCrewSupport]
{
O2Amount = #$@IONCROSS_MM_SETTINGS/O2$
CO2Amount = #$@IONCROSS_MM_SETTINGS/CO2$

@O2Amount *= #$CrewCapacity$
@CO2Amount *= #$CrewCapacity$


MODULE
{
name = IonModuleCrewSupport
}
RESOURCE
{
name = Oxygen
amount = #$/O2Amount$
maxAmount = #$/O2Amount$
}
RESOURCE
{
name = CarbonDioxide
amount = 0
maxAmount = #$/CO2Amount$
}
}

Link to comment
Share on other sites

suggestion, allow numbered-value keys to accept value of other keys, ie

@PART

{

CrewCapacity = 5

MODULE

{

ResourceAmount = CrewCapacity * 5 <- this

}

}

currently i'm making 40 patches, for 1 2 3 4 ... 40 crew, when the above could simplify it into 1 patch :)

See http://forum.kerbalspaceprogram.com/threads/55219-Module-Manager-2-3-5-%28Sept-14%29-Loading-Speed-Fix?p=1416253&viewfull=1#post1416253 for the syntax that's been available since MM 2.3.5. The link in the OP isn't the easiest thing in the world to see, but it's there.

I think your use case would look something like


@PART {
%CrewCapacity = 5
MODULE {
ResourceAmount = #$../CrewCapacity$
@ResourceAmount *= 5
}
}

Link to comment
Share on other sites

ResourceAmount = #$../CrewCapacity$ * 5

I think that's how the variable system works... (spitballed from this post)

Only thing is you can't do math within the value side. Your code would set ResourceAmount to the string "5 * 5". To actually get MM to evaluate the math, you have to do the two-line assign and then *=.

Link to comment
Share on other sites

Only thing is you can't do math within the value side. Your code would set ResourceAmount to the string "5 * 5". To actually get MM to evaluate the math, you have to do the two-line assign and then *=.

Yea, I see that from all the ones that got there before me :P (I seem to have left the window open...)

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