Jump to content

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


sarbian

Recommended Posts

Can work this patch ?

 

@PART[PotatoRoid]
{
	@MODULE[ModuleAsteroid]
	{
	@mass =	#$mass/10
	}

	RESOURCE
	{
	 name = Rock
	 amount = 3600
	 maxAmount = 3600
	 @amount *= #$/mass$
	 @maxAmount *= #$/mass$
	}
}

what i want is have mass=mass/10 and the resource mass/10*amount

Link to comment
Share on other sites

18 minutes ago, Badsector said:

This should do it if I understood what you want


@PART[PotatoRoid]
{
	@MODULE[ModuleAsteroid]
	{
	@mass /=	10
	}

	RESOURCE
	{
	 name = Rock
	 amount = 3600
	 maxAmount = 3600
	 @amount *= #$../MODULE[ModuleAsteroid]/mass$
	 @maxAmount *= #$../MODULE[ModuleAsteroid]/mass$
	}
}

 

 

Edited by sarbian
Link to comment
Share on other sites

5 minutes ago, sarbian said:

 

Thanks,

i have do one misspelling but probably the correct code is

@PART[PotatoRoid]
{
@mass =	#$mass/10

	RESOURCE
	{
	 name = Rock
	 amount = 3600
	 maxAmount = 3600
	 @amount *= #$../mass$
	 @maxAmount *= #$../mass$
	}
}

on this way if asteroid have mass = 150 the result is
 

mass = 15

    RESOURCE
    {
     name = Rock
     amount = 54000 (3600*15)
     maxAmount = 54000 (3600*15)
    }

 

Link to comment
Share on other sites

A bug report in my SMURFF thread got me thinking about errors and caching.  Currently, as Module Manager does its work, it makes a note in the log of errors that it encounters -- which file and patch caused them, and maybe what part it was acting on (it's been a while since I've seen an MM error).  However, when KSP gets restarted, assuming nothing changes, Module Manager loads the cache, errors and all, and doesn't say anything in the log because it's "forgotten" that any errors occurred at all.  I'm not sure that errors should force a reload of all patches (presumably, if the cache is loaded, nothing's changed, so the errors would just happen again anyway), but I think at the least, errors should be stored in the cache as well, so that when MM loads the cache, it can add a reminder that those errors were thrown when the patches were originally processed.

Link to comment
Share on other sites

9 minutes ago, Kerbas_ad_astra said:

A bug report in my SMURFF thread got me thinking about errors and caching.  Currently, as Module Manager does its work, it makes a note in the log of errors that it encounters -- which file and patch caused them, and maybe what part it was acting on (it's been a while since I've seen an MM error).  However, when KSP gets restarted, assuming nothing changes, Module Manager loads the cache, errors and all, and doesn't say anything in the log because it's "forgotten" that any errors occurred at all.  I'm not sure that errors should force a reload of all patches (presumably, if the cache is loaded, nothing's changed, so the errors would just happen again anyway), but I think at the least, errors should be stored in the cache as well, so that when MM loads the cache, it can add a reminder that those errors were thrown when the patches were originally processed.

I've had this issue many times as well

 

I usually end up asking the player to delete the cache before generating the logs :)

Link to comment
Share on other sites

I'm trying to get the value of the baseVolume variable from a module and change that part's title to it (for debugging purposes)

Spoiler

@PART[*]:HAS[@MODULE[ModuleB9PartSwitch]]:HAS[#moduleID[fuelSwitch]]:FINAL
{
    LFAmount = 1
    @MODULE[ModuleB9PartSwitch]
    {
        @$/../LFAmount$ = #$baseVolume$
    }
    @title = #$LFAmount$
}

But with this the title just ends up being "1".

Link to comment
Share on other sites

Yes, because the order of execution is not what your think. MM see only the config after they are parsed by KSP so what it actually see (and do) is :

@PART[*]:HAS[@MODULE[ModuleB9PartSwitch]]:HAS[#moduleID[fuelSwitch]]:FINAL
{
    LFAmount = 1
    @title = #$LFAmount$
    @MODULE[ModuleB9PartSwitch]
    {
        @$/../LFAmount$ = #$baseVolume$
    }
} 

To do this kind of things you need to apply 2 patch.

Link to comment
Share on other sites

1 hour ago, ShadyAct said:

I'm trying to get the value of the baseVolume variable from a module and change that part's title to it (for debugging purposes)

  Reveal hidden contents

@PART[*]:HAS[@MODULE[ModuleB9PartSwitch]]:HAS[#moduleID[fuelSwitch]]:FINAL
{
    LFAmount = 1
    @MODULE[ModuleB9PartSwitch]
    {
        @$/../LFAmount$ = #$baseVolume$
    }
    @title = #$LFAmount$
}

But with this the title just ends up being "1".

A few things

  • If you're just debugging, you might want to look at ModuleManager.configcache in GameData.  It contains the final state of everything in the game database after MM runs (and right before the parts are loaded).
  • I wouldn't recommend relying on moduleID to identify the fuel switching modules.  I tried to use conventions throughout B9, but the only requirement is that it is unique per ModuleB9PartSwitch.
  • If you're trying to do something with the volume, you might want to look at the RF/MFT patches in B9
Link to comment
Share on other sites

24 minutes ago, blowfish said:

A few things

  • If you're just debugging, you might want to look at ModuleManager.configcache in GameData.  It contains the final state of everything in the game database after MM runs (and right before the parts are loaded).
  • I wouldn't recommend relying on moduleID to identify the fuel switching modules.  I tried to use conventions throughout B9, but the only requirement is that it is unique per ModuleB9PartSwitch.
  • If you're trying to do something with the volume, you might want to look at the RF/MFT patches in B9

Thanks. Once I get better at this I'm going to publish a book called, "Module Manager for Dummies".

Edit: Is there a programming language that resembles Module Manager code? I want to get better syntax highlighting in Notepad++, if possible.

Edited by ShadyAct
Link to comment
Share on other sites

To change a value you just need to do a @valuename = new value.

But your problem is not ModuleManager here. The mesh value only work for model that are in the same directory than the cfg. You need a MODEL node to change that AFAIK but that s a bit outside my experience field. Have a look at post like this one

Link to comment
Share on other sites

[LOG 12:11:16.053] [ModuleManager] Saving cache
[LOG 12:11:16.255] [ModuleManager] NullReferenceException while saving the cache
System.NullReferenceException: Object reference not set to an instance of an object
  at (wrapper stelemref) object:stelemref (object,intptr,object)
  at ConfigNode.WriteNodeString (System.IO.StreamWriter sw, System.String indent) [0x00000] in <filename unknown>:0 
  at ConfigNode.WriteNodeString (System.IO.StreamWriter sw, System.String indent) [0x00000] in <filename unknown>:0 
  at ConfigNode.WriteRootNode (System.IO.StreamWriter sw) [0x00000] in <filename unknown>:0 
  at ConfigNode.WriteNode (System.IO.StreamWriter sw) [0x00000] in <filename unknown>:0 
  at ConfigNode.Save (System.String fileFullName, System.String header) [0x00000] in <filename unknown>:0 
  at ConfigNode.Save (System.String fileFullName) [0x00000] in <filename unknown>:0 
  at ModuleManager.MMPatchLoader.CreateCache () [0x00000] in <filename unknown>:0 
[LOG 12:11:16.265] [ModuleManager] An error occured while creating the cache. Deleting the cache files to avoid keeping a bad cache
[LOG 12:11:16.269] [ModuleManager] Exception while deleting the cache
System.IO.IOException: Sharing violation on path C:/Program Files (x86)/Steam/steamapps/common/Kerbal Space Program/KSP_Data/../\GameData\ModuleManager.ConfigCache
  at System.IO.File.Delete (System.String path) [0x00000] in <filename unknown>:0 
  at ModuleManager.MMPatchLoader.CreateCache () [0x00000] in <filename unknown>:0 
[LOG 12:11:16.288] [ModuleManager] ModuleManager: 6684 patches applied

 

Was wondering why cache runs was so rare on my system lately. Not sure whats up with this, sometimes it create the cache just fine.

That was a run where the only change was to MyMM.cfg, my own MM file and while exiting KSP gracefully. (Not due to Memory crash)

[LOG 12:45:44.461] [ModuleManager] Saving cache
[LOG 12:45:45.128] [ModuleManager] ModuleManager: 6684 patches applied

Now the second run, again due to editing MyMM.cfg, it happily creates the cache.

 

I would have added a third run, without changing anything, where the cache should be loaded, but I couldn't help myself and added some comments to MyMM.cfg.

 

Link to comment
Share on other sites

1 hour ago, KerbonautInTraining said:

Just to be sure, if I delete all but the latest version of MM will I have any backwards compatibility issues?

Even if you don't the older versions should disable themselves, but yes - you are fine to delete them.

Link to comment
Share on other sites

On 28/2/2016 at 0:59 PM, Miravlix said:

[LOG 12:11:16.053] [ModuleManager] Saving cache
[LOG 12:11:16.255] [ModuleManager] NullReferenceException while saving the cache
System.NullReferenceException: Object reference not set to an instance of an object
  at (wrapper stelemref) object:stelemref (object,intptr,object)
  at ConfigNode.WriteNodeString (System.IO.StreamWriter sw, System.String indent) [0x00000] in <filename unknown>:0 
  at ConfigNode.WriteNodeString (System.IO.StreamWriter sw, System.String indent) [0x00000] in <filename unknown>:0 
  at ConfigNode.WriteRootNode (System.IO.StreamWriter sw) [0x00000] in <filename unknown>:0 
  at ConfigNode.WriteNode (System.IO.StreamWriter sw) [0x00000] in <filename unknown>:0 
  at ConfigNode.Save (System.String fileFullName, System.String header) [0x00000] in <filename unknown>:0 
  at ConfigNode.Save (System.String fileFullName) [0x00000] in <filename unknown>:0 
  at ModuleManager.MMPatchLoader.CreateCache () [0x00000] in <filename unknown>:0 
[LOG 12:11:16.265] [ModuleManager] An error occured while creating the cache. Deleting the cache files to avoid keeping a bad cache
[LOG 12:11:16.269] [ModuleManager] Exception while deleting the cache
System.IO.IOException: Sharing violation on path C:/Program Files (x86)/Steam/steamapps/common/Kerbal Space Program/KSP_Data/../\GameData\ModuleManager.ConfigCache
  at System.IO.File.Delete (System.String path) [0x00000] in <filename unknown>:0 
  at ModuleManager.MMPatchLoader.CreateCache () [0x00000] in <filename unknown>:0 
[LOG 12:11:16.288] [ModuleManager] ModuleManager: 6684 patches applied

 

Was wondering why cache runs was so rare on my system lately. Not sure whats up with this, sometimes it create the cache just fine.

That was a run where the only change was to MyMM.cfg, my own MM file and while exiting KSP gracefully. (Not due to Memory crash)


[LOG 12:45:44.461] [ModuleManager] Saving cache
[LOG 12:45:45.128] [ModuleManager] ModuleManager: 6684 patches applied

Now the second run, again due to editing MyMM.cfg, it happily creates the cache.

 

I would have added a third run, without changing anything, where the cache should be loaded, but I couldn't help myself and added some comments to MyMM.cfg.

 

I feel that an Antivirus or Window protection blocked the file operations in "C:/Program Files (x86)". I strongly suggest you create an new Steam library outside "C:/Program Files (x86)" and reinstall KSP there.

Link to comment
Share on other sites

Hi, I'm kind of stuck here can anyone have a quick look at this and tell me what I'm doing wrong?

@PART[*]:HAS[@MODULE[ModuleFuelJettison]]
{
	%SimpleAm = #$RESOURCE[Ore]/maxAmount$
	%DoubleAm = #$SimpleAm$
	@DoubleAm *= 2
	%Weight = #$mass$
	
	MODULE
	{
		name = InterstellarFuelSwitch
		resourceNames = Ore;Metal;RocketParts
		resourceAmounts = #$SimpleAm$;#$SimpleAm$;#$DoubleAm$
		tankMass = #$Weight$;#$Weight$;#$Weight$
		basePartMass = 0.0
		displayCurrentTankCost = true
		hasGUI = true
		availableInFlight = false
		availableInEditor = true
		showInfo = true	
	}
}

For some reason it refuses to work the way I want.

The intended use is to apply the fuelswitch to all ore tanks at once.

 

Link to comment
Share on other sites

5 hours ago, maculator said:

Hi, I'm kind of stuck here can anyone have a quick look at this and tell me what I'm doing wrong?

 

 

For some reason it refuses to work the way I want.

The intended use is to apply the fuelswitch to all ore tanks at once.

This should do it. I added a check for Ore since checking for ModuleFuelJettison only seem a bit hazardous. And I fixed the variable syntax (# is only used once per line) and variable search (../ for a variable in a lower context)

@PART[*]:HAS[@MODULE[ModuleFuelJettison],@RESOURCE[Ore]]
{
	%SimpleAm = #$RESOURCE[Ore]/maxAmount$
	%DoubleAm = #$SimpleAm$
	@DoubleAm *= 2
	%Weight = #$mass$
	
	MODULE
	{
		name = InterstellarFuelSwitch
		resourceNames = Ore;Metal;RocketParts
		resourceAmounts = #$../SimpleAm$;$../SimpleAm$;$../DoubleAm$
		tankMass = #$../Weight$;$../Weight$;$../Weight$
		basePartMass = 0.0
		displayCurrentTankCost = true
		hasGUI = true
		availableInFlight = false
		availableInEditor = true
		showInfo = true	
	}
}

 

 

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