Jump to content

[1.10.1+] Contract Configurator [v1.30.5] [2020-10-05]


nightingale

Recommended Posts

22 minutes ago, Caerfinon said:

An easier way would be to remove all unmet requirements (or comment them out) and then the contract will be offered.

 

2 hours ago, Krzeszny said:

What would a contract look like if it had 2 parameters:
Parameter 1 would check for module x (unspecified part) and gave a specific reward (multiple parts have that module)
Parameter 2 would check for one specific part (which has module x in it) but gave a different reward?

I know how to check for errors (the Ctrl+Alt+F10 menu) but not how to "spawn" a contract if not all requirements have been met, so testing it isn't that easy.

Alternatively, it is possible to deactivate a requirement while in-game, through the CC debug menu. Just click on the green check icon next to the requirement after browsing to it.

Be mindful however, I have found the contract can behave strangely when using this method (blinking in and out of existence), I only use it to check if it is loaded correctly, never to actually playtest. It's one of those features that's not quite functioning right.

Link to comment
Share on other sites

Hi again. I'm still working on a pull request that would make this mod compatible with SSPXR and USI. Among other new mod-specific parameters, I added this under the vanilla science lab:

			PARAMETER:NEEDS[StationPartsExpansionRedux]
			{
				name = PartValidation
				type = PartValidation
				title = Include an SDV-X 'Cronus' Extensible Centrifuge
				rewardFunds = 181000.0
				hideChildren = true
				
				part = sspx-expandable-centrifuge-5-1
			}

After uninstalling Stockalike Station Parts Expansion Redux and making sure a folder named StationPartsExpansionRedux isn't in  GameData, I'm getting this in my career save:

ncC7QEG.png

Fulll error:

Spoiler
Exception occured while loading contract parameter 'PartValidation' in contract 'BasesandStations.StationCore':
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: 'sspx-expandable-centrifuge-5-1' is not a valid Part.
  at ContractConfigurator.ConfigNodeUtil.ParsePartValue (System.String partName) [0x00025] in <ef0243a06f2841fe9bf57034a334902e>:0 
  at ContractConfigurator.ConfigNodeUtil.ParseSingleValue[T] (System.String key, System.String stringValue, System.Boolean allowExpression) [0x000f9] in <ef0243a06f2841fe9bf57034a334902e>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <9577ac7a62ef43179789031239ba8798>:0 
   --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at ContractConfigurator.ConfigNodeUtil.ParseValue[T] (ConfigNode configNode, System.String key, System.Boolean allowExpression) [0x001f0] in <ef0243a06f2841fe9bf57034a334902e>:0 
  at ContractConfigurator.ConfigNodeUtil.ParseValue[T] (ConfigNode configNode, System.String key, T defaultValue) [0x00012] in <ef0243a06f2841fe9bf57034a334902e>:0 
  at ContractConfigurator.Parameters.PartValidation.OnParameterLoad (ConfigNode node) [0x00079] in <ef0243a06f2841fe9bf57034a334902e>:0 
  at ContractConfigurator.Parameters.ContractConfiguratorParameter.OnLoad (ConfigNode node) [0x000be] in <ef0243a06f2841fe9bf57034a334902e>:0 

 

Why and how?

Edited by Krzeszny
formatting
Link to comment
Share on other sites

40 minutes ago, Krzeszny said:

Why and how?

Have you turned on Contract Configurator debugging? If so post a copy of the log for the contract.  If not look at the file ContractConfigurator.cfg.default and follow instructions to turn on debug logging and generate the error again.

Link to comment
Share on other sites

14 minutes ago, Caerfinon said:

Have you turned on Contract Configurator debugging? If so post a copy of the log for the contract.  If not look at the file ContractConfigurator.cfg.default and follow instructions to turn on debug logging and generate the error again.

Here's the log from these settings (triple DEBUG because I didn't know what to choose):

Spoiler
CC_DEBUGGING
{
	// Possible LogLevel: VERBOSE, DEBUG, INFO, WARNING, ERROR
	logLevel = DEBUG
	
	ADD_LOGLEVEL_EXCEPTION
	{
		// Type name
		type = ContractConfigurator
		// Possible LogLevel: VERBOSE, DEBUG, INFO, WARNING, ERROR
		logLevel = DEBUG
	}
	
	ADD_LOGLEVEL_EXCEPTION
	{
		// Type name
		type = ContractType
		// Possible LogLevel: VERBOSE, DEBUG, INFO, WARNING, ERROR
		logLevel = DEBUG
	}
}

 

https://drive.google.com/file/d/1-QmLtpFuqF8NzSZphk17B7XttWIa4fJ4/view?usp=sharing

Link to comment
Share on other sites

5 minutes ago, Krzeszny said:

Here's the log

So the contract Configurator log shows the contract parsed correctly with only the science lab present;

		PARAMETER
		{
			name = ScienceModuleValidation
			type = Any
			optional = true
			completeInSequence = true
			targetBody = @/targetBody
			PARAMETER
			{
				name = ScienceLab
				type = PartValidation
				title = Include a TEST LAB SO CHECK IT OUT, NAOW
				rewardFunds = 75000.0
				hideChildren = true
				partModule = ModuleScienceLab
				targetBody = @/targetBody
			}
		}

That should be the contract that is offered in-game as it loaded successfully  without the StationPartsExpansionRedux parameter.  Do you see it as offered?

Link to comment
Share on other sites

9 minutes ago, Caerfinon said:

So the contract Configurator log shows the contract parsed correctly with only the science lab present;

		PARAMETER
		{
			name = ScienceModuleValidation
			type = Any
			optional = true
			completeInSequence = true
			targetBody = @/targetBody
			PARAMETER
			{
				name = ScienceLab
				type = PartValidation
				title = Include a TEST LAB SO CHECK IT OUT, NAOW
				rewardFunds = 75000.0
				hideChildren = true
				partModule = ModuleScienceLab
				targetBody = @/targetBody
			}
		}

That should be the contract that is offered in-game as it loaded successfully  without the StationPartsExpansionRedux parameter.  Do you see it as offered?

(lol, I forgot to change that test name.)

No, I see all of them:

qkILgbc.png

And the CC debug menu shows only what should be there without SSPXR installed:

Spoiler

L80QOpx.png

I'm pretty sure it's because I uninstalled the mod that adds those labs and I keep loading a save that has a contract for them.

At the same time I wasn't expecting CC to throw an exception because of uninstalling a mod.

Edited by Krzeszny
save?
Link to comment
Share on other sites

6 minutes ago, Krzeszny said:

I'm pretty sure it's because I uninstalled the mod that adds those labs and I keep loading a save that has a contract for them.

At the same time I wasn't expecting CC to throw an exception because of uninstalling a mod.

And the light comes on... Once a contract is offered it is recorded in the form it was offered in into the contract section of the persistent.sfs file of your game. It works on the same principal as a ship you have in orbit when you remove a parts mod. If the stored offered contract is looking for the part but the mod is removed then CC has a hissy fit that the part is gone. Meanwhile any new offered contracts should ignore the part as per the new version of the loaded contract.

Link to comment
Share on other sites

On 9/27/2021 at 6:53 PM, Caerfinon said:

And the light comes on... Once a contract is offered it is recorded in the form it was offered in into the contract section of the persistent.sfs file of your game. It works on the same principal as a ship you have in orbit when you remove a parts mod. If the stored offered contract is looking for the part but the mod is removed then CC has a hissy fit that the part is gone. Meanwhile any new offered contracts should ignore the part as per the new version of the loaded contract.

You're not saying the exception is normal and it's ok that the message that says "Avoid saving your game and backup yous save immediatelly", right?

If this exception doesn't break anything, it shouldn't be an exception.

Edited by Krzeszny
shouldn't, not should
Link to comment
Share on other sites

@Krzeszny I'm more saying that the removal of a part mod from an active game produces unintended consequences. Broken ships, broken Contract  Configurator contracts. The code throws the exception because it is working off of old information. Contract configurator does not cleanup contracts already stored in the persistent.sfs when the game loads. Therefore when it encounters the missing part in the stale contract, it throws an exception because it has no other way to resolve the issue. 

So in this specific instance, the exception is very little to worry about, but i suspect that there is only a single bit of code that posts messages for any and all exceptions, so caution is the watchword when catching the serious and the trivial.

Link to comment
Share on other sites

  • 2 weeks later...

HI,

One of the mods I support is a contract pack called Bases & Stations.  In one of the contract, there is a requirement for a specific part:

		//OPTIONAL Checks for cupola
		PARAMETER
        {
            name = PartValidation
            type = PartValidation
            title = Include a cupola (optional)
			optional = true
			hideChildren = true
            
            part = cupola
            minCount = 1
            
        }

Problem is that this is for a specific stock part, and I'd like to change it to allow any part with "cupola" anywhere  in the part name or title, not sure how to do this.

Can someone help? 

I and others will thank you

Edited by linuxgurugamer
Link to comment
Share on other sites

25 minutes ago, linuxgurugamer said:

Problem is that this is for a specific stock part, and I'd like to change it to allow any part with "cupola" in the title, not sure how to do this.

There is no way to do this directly through CC.
A workaround could be to use MM patches to detected cupolas, and to add a dummy PartModule so you can detect it through the partModule PartValidation parameter (check documentation here : https://github.com/jrossignol/ContractConfigurator/wiki/PartValidation-Parameter)
I would suggest making a tiny dll with an empty PartModule derivative named something like "ModuleCupolaContractValidation" for the purpose.

Side note : checking the part title or tags will fail due to localization. You can only (somewhat) rely on the part name.

Link to comment
Share on other sites

24 minutes ago, Gotmachine said:

There is no way to do this directly through CC.
A workaround could be to use MM patches to detected cupolas, and to add a dummy PartModule so you can detect it through the partModule PartValidation parameter (check documentation here : https://github.com/jrossignol/ContractConfigurator/wiki/PartValidation-Parameter)
I would suggest making a tiny dll with an empty PartModule derivative named something like "ModuleCupolaContractValidation" for the purpose.

Side note : checking the part title or tags will fail due to localization. You can only (somewhat) rely on the part name.

I was afraid of that.  Wanted to avoid yet another dll, but at least it's not difficult, just tedious.

Thanks

Link to comment
Share on other sites

2 minutes ago, linuxgurugamer said:

Wanted to avoid yet another dll, but at least it's not difficult, just tedious.

If you really want to avoid it, you can use a dummy ModuleDragModifier, which has no code and is just being checked at the part prefab compilation.
As long as you don't touch the default "1f" value of its " dragModifier" field, it's garanteed to have zero effect.
But it has a "dragCubeName" string KSPField that you can check with the CC extended partmodule check.

Link to comment
Share on other sites

1 hour ago, Gotmachine said:

Side note : checking the part title or tags will fail due to localization. You can only (somewhat) rely on the part name.

This I know, unfortunately

1 hour ago, Gotmachine said:

If you really want to avoid it, you can use a dummy ModuleDragModifier, which has no code and is just being checked at the part prefab compilation.
As long as you don't touch the default "1f" value of its " dragModifier" field, it's garanteed to have zero effect.
But it has a "dragCubeName" string KSPField that you can check with the CC extended partmodule check.

Well, I've made the dll already, it's not going to hurt, but I'll look at this, thanks.

Link to comment
Share on other sites

  • 2 weeks later...
3 hours ago, linuxgurugamer said:

A problem has been reported to me about parts being referenced in a contract which don't exist:

Can this be fixed?

When specifying requirements or objectives for a specific part from a different mod, always add a ":NEEDS[modname] to the node in question. Though beware, this also means the node won't be loaded at all if the needs isn't being met. You might need multiple nodes for all parts/functions you're trying to use this way.

Link to comment
Share on other sites

3 hours ago, Morphisor said:

When specifying requirements or objectives for a specific part from a different mod, always add a ":NEEDS[modname] to the node in question. Though beware, this also means the node won't be loaded at all if the needs isn't being met. You might need multiple nodes for all parts/functions you're trying to use this way.

I realize that, and will have to do that,  but would be nice if CC could ignore those errors

Link to comment
Share on other sites

Is it possible to have a NEEDS on a single line, like this:

part = ht2_moduleCupola:NEEDS[HabTech2]

I tend to doubt it, but figured I'd ask.

Assuming that doesn't work, how can I have several PartValidation parameters, and only require 1 of them?

Edited by linuxgurugamer
Link to comment
Share on other sites

19 minutes ago, linuxgurugamer said:

Is it possible to have a NEEDS on a single line, like this:

part = ht2_moduleCupola:NEEDS[HabTech2]

I tend to doubt it, but figured I'd ask.

Assuming that doesn't work, how can I have several PartValidation parameters, and only require 1 of them?

I'm not sure about having NEEDS on a single line, but perhaps you could use the Any parameter? That should allow you to apply NEEDS to each child parameter.

https://github.com/jrossignol/ContractConfigurator/wiki/Any-Parameter

Edited by Zelda
Link to comment
Share on other sites

14 minutes ago, Zelda said:

I'm not sure abobut having NEEDS on a single line, but perhaps you could use the Any parameter? That should allow you to apply NEEDS to each child parameter.

https://github.com/jrossignol/ContractConfigurator/wiki/Any-Parameter

Unfortunatly, no.  REQUIREMENT is a prereq, I need to do this on a PARAMETER,

Which, nicely enough, also has the ANY 

Link to comment
Share on other sites

As the mod requested, here's a thrown exception:

Quote

Exception occured while saving ScenarioModule 'ContractVesselTracker':
System.NullReferenceException: Object reference not set to an instance of an object
  at ContractConfigurator.Extensions+<>c__DisplayClass5_1.<GetHashes>b__1 (ProtoPartSnapshot childPart) [0x00000] in <ef0243a06f2841fe9bf57034a334902e>:0 
  at System.Linq.Enumerable+WhereListIterator`1[TSource].MoveNext () [0x00037] in <351e49e2a5bf4fd6beabb458ce2255f3>:0 
  at System.Linq.Enumerable.TryGetFirst[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Boolean& found) [0x00045] in <351e49e2a5bf4fd6beabb458ce2255f3>:0 
  at System.Linq.Enumerable.FirstOrDefault[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00000] in <351e49e2a5bf4fd6beabb458ce2255f3>:0 
  at ContractConfigurator.Extensions+<GetHashes>d__5.MoveNext () [0x00364] in <ef0243a06f2841fe9bf57034a334902e>:0 
  at System.Linq.Enumerable.Contains[TSource] (System.Collections.Generic.IEnumerable`1[T] source, TSource value, System.Collections.Generic.IEqualityComparer`1[T] comparer) [0x00036] in <351e49e2a5bf4fd6beabb458ce2255f3>:0 
  at System.Linq.Enumerable.Contains[TSource] (System.Collections.Generic.IEnumerable`1[T] source, TSource value) [0x0000a] in <351e49e2a5bf4fd6beabb458ce2255f3>:0 
  at ContractConfigurator.ContractVesselTracker+<>c__DisplayClass15_0.<OnSave>b__1 (Vessel v) [0x0000f] in <ef0243a06f2841fe9bf57034a334902e>:0 
  at System.Collections.Generic.List`1[T].Find (System.Predicate`1[T] match) [0x0000d] in <9577ac7a62ef43179789031239ba8798>:0 
  at ContractConfigurator.ContractVesselTracker.OnSave (ConfigNode node) [0x00060] in <ef0243a06f2841fe9bf57034a334902e>:0 

 

Link to comment
Share on other sites

13 hours ago, luna_cat said:

As the mod requested, here's a thrown exception:

 

Without context nobody can help you with this. CC doesn't throw any errors like this by itself. Which contracts are involved, what are you doing when this error pops, etc.

11 hours ago, WindupHero7 said:

Is it possible for some contract packs to be blocking others? No matter how many contracts I refuse, it seems I'm always offered the same few types from the same few packs even though I know I've got requirements met for other packs

Sometimes it takes a while for technically available contracts to actually generate, the generation code has some oddities in it. Try waiting for several ingame days. Alternatively, I've found that simply browsing through the admin/science/astronaut/mission control buildings for a few minutes triggers generation of certain types of contracts too. If neither works, you're not matching the requirements or there's other things preventing the contract from generating.

Link to comment
Share on other sites

13 hours ago, Morphisor said:

Without context nobody can help you with this. CC doesn't throw any errors like this by itself. Which contracts are involved, what are you doing when this error pops, etc.

The mod requests that I paste the "info below" into this thread. I did what was requested.

The error happened just after completing the Oddiseo Project Yliad contract.

Link to comment
Share on other sites

5 hours ago, luna_cat said:

The mod requests that I paste the "info below" into this thread. I did what was requested.

The error happened just after completing the Oddiseo Project Yliad contract.

The mod is telling you do the bare minimum and, as @Morphisor suggested, more insight will be necessary.  Read the topic at the link below and provide the info it asks for, otherwise there isn't much hope of getting a meaningful response.  If you're going to the trouble of posting here, help yourself and others by providing as much info as practical to assist in the detective work on your behalf.

 

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