Jump to content

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


nightingale

Recommended Posts

Exception occured while saving ScenarioModule 'ContractVesselTracker':

System.InvalidOperationException: Operation is not valid due to the current state of the object

at System.Linq.Enumerable.First[ProtoPartSnapshot] (IEnumerable`1 source) [0x00000] in <filename unknown>:0

at ContractConfigurator.Extensions+<GetHashes>d__18.MoveNext () [0x00000] in <filename unknown>:0

at System.Linq.Enumerable.Contains[uInt32] (IEnumerable`1 source, UInt32 value, IEqualityComparer`1 comparer) [0x00000] in <filename unknown>:0

at System.Linq.Enumerable.Contains[uInt32] (IEnumerable`1 source, UInt32 value) [0x00000] in <filename unknown>:0

at ContractConfigurator.ContractVesselTracker+<>c__DisplayClass6.<OnSave>b__4 (.Vessel v) [0x00000] in <filename unknown>:0

at System.Collections.Generic.List`1[Vessel].GetIndex (Int32 startIndex, Int32 count, System.Predicate`1 match) [0x00000] in <filename unknown>:0

at System.Collections.Generic.List`1[Vessel].Find (System.Predicate`1 match) [0x00000] in <filename unknown>:0

at ContractConfigurator.ContractVesselTracker.OnSave (.ConfigNode node) [0x00000] in <filename unknown>:0 ​

Link to comment
Share on other sites

Okay, give the dev dll a try. You should be able to get it working with something like this:


DATA
{
type = double
orbitperiodmin = @targetBody.RotationalPeriod() * 0.99
orbitperiodmax = @targetBody.RotationalPeriod() * 1.01
}

PARAMETER
{
name = Orbit
type = Orbit
maxInclination = 3
maxEccentricity = 0.05

minPeriod = @/orbitperiodmin
maxPeriod = @/orbitperiodmax
}

That looks to be working just fine. Thanks!

Exception occured while saving ScenarioModule 'ContractVesselTracker':

System.InvalidOperationException: Operation is not valid due to the current state of the object

at System.Linq.Enumerable.First[ProtoPartSnapshot] (IEnumerable`1 source) [0x00000] in <filename unknown>:0

at ContractConfigurator.Extensions+<GetHashes>d__18.MoveNext () [0x00000] in <filename unknown>:0

at System.Linq.Enumerable.Contains[uInt32] (IEnumerable`1 source, UInt32 value, IEqualityComparer`1 comparer) [0x00000] in <filename unknown>:0

at System.Linq.Enumerable.Contains[uInt32] (IEnumerable`1 source, UInt32 value) [0x00000] in <filename unknown>:0

at ContractConfigurator.ContractVesselTracker+<>c__DisplayClass6.<OnSave>b__4 (.Vessel v) [0x00000] in <filename unknown>:0

at System.Collections.Generic.List`1[Vessel].GetIndex (Int32 startIndex, Int32 count, System.Predicate`1 match) [0x00000] in <filename unknown>:0

at System.Collections.Generic.List`1[Vessel].Find (System.Predicate`1 match) [0x00000] in <filename unknown>:0

at ContractConfigurator.ContractVesselTracker.OnSave (.ConfigNode node) [0x00000] in <filename unknown>:0 ​

You aren't providing enough info here most likely.

What version of Contract Configurator are you on? Newest is 1.6.4. What version of KSP? What contract packs do you have installed? When do you see this error? What other mods do you have installed?

Link to comment
Share on other sites

I'm wondering if it is possible to modify the contract given below so that the following needs to happen;

1. needs 3 orbits in order to unlock the next contract in the list

2. needs 3 different vessels created/launched after the contract is accepted

3. needs 3 different kerbal names to orbit kerbin

Right now I could accept the contract and already have a kerbal orbiting kerbin and the timer is already counting down

//---Manned Orbit---\\

CONTRACT_TYPE

{

name = MannedOrbit

title = Manned Orbit and safe return!

description = While reaching orbit with a probe was quite an accomplishment, sending a kerbal up there will be great inspiration for kerbalkind and thus an important milestone for our space program.

synopsis = We want you to launch a kerbal into an orbit around Kerbin and then return him safely.

completedMessage = You have successfully completed the first manned orbital mission around Kerbin.

agent = Space Exploration & Technology Initiative

minExpiry = 852.0

maxExpiry = 852.0

cancellable = true

declinable = true

prestige = Significant

targetBody = Kerbin

maxCompletions = 1

maxSimultaneous = 1

rewardScience = 18.0

rewardReputation = 80.0

rewardFunds = 72000.0

failureFunds = 24000.0

advanceFunds = 24000.0

PARAMETER

{

name = OrbitKerbin

type = VesselParameterGroup

duration= 40m

PARAMETER

{

name = HasCrew

type = HasCrew

minCrew = 1

}

PARAMETER

{

name = ReachState

type = ReachState

situation = ORBITING

disableOnStateChange = false

}

PARAMETER

{

name = ReturnHome

type = ReturnHome

}

}

BEHAVIOUR

{

name = Progression

type = Expression

CONTRACT_COMPLETED_SUCCESS

{

setiMannedOrbit = 10

}

}

REQUIREMENT

{

name = All

type = All

REQUIREMENT

{

name = Progression

type = Expression

expression = setiMannedAltitude18km == 10

}

REQUIREMENT

{

name = Progression

type = Expression

expression = setiOrbitRecovery == 10

}

}

}

Link to comment
Share on other sites

Thanks for adding my requested part unlocking!

I've another request. This one isn't critical but will save me a bit of work and a lot of files in my eventual pack. Right now you can spawn a vessel or a Kerbal (or passengers, but that's not exactly he same thing). Would it be possible to either add SpawnPart (with all the options of SpawnVessel minus the craft file. instead, a part name), or modify SpawnVessel to accept a part instead of a craft file?

It'll save me having to create a craft for every single part in the game and will make supporting mods easier down the line.

Link to comment
Share on other sites

I'm wondering if it is possible to modify the contract given below so that the following needs to happen;

1. needs 3 orbits in order to unlock the next contract in the list

2. needs 3 different vessels created/launched after the contract is accepted

3. needs 3 different kerbal names to orbit kerbin

PARAMETER
{
name = OrbitKerbin
type = VesselParameterGroup
duration= 40m

[COLOR="#FF0000"] PARAMETER
{
name = NewVessel
type = NewVessel
}[/COLOR]

PARAMETER
{
name = HasCrew
type = HasCrew

minCrew = 1
}

PARAMETER
{
name = ReachState
type = ReachState

situation = ORBITING
disableOnStateChange = false
}


PARAMETER
{
name = ReturnHome
type = ReturnHome
}
}

Put in the red text in that group.

Three orbits meaning orbit around the planet 3 times?

You could easily extend the duration.

If you instead mean you need to complete that contract 3 times then it can be done, but is more complicated.

Likewise your 3rd request is possible using behaviors so check that section out on the docs.

Link to comment
Share on other sites

Thanks for adding my requested part unlocking!

I've another request. This one isn't critical but will save me a bit of work and a lot of files in my eventual pack. Right now you can spawn a vessel or a Kerbal (or passengers, but that's not exactly he same thing). Would it be possible to either add SpawnPart (with all the options of SpawnVessel minus the craft file. instead, a part name), or modify SpawnVessel to accept a part instead of a craft file?

It'll save me having to create a craft for every single part in the game and will make supporting mods easier down the line.

That should be easy enough, that's already what SpawnKerbal does. Raised [#290].

I'm wondering if it is possible to modify the contract given below so that the following needs to happen;

1. needs 3 orbits in order to unlock the next contract in the list

2. needs 3 different vessels created/launched after the contract is accepted

3. needs 3 different kerbal names to orbit kerbin

Right now I could accept the contract and already have a kerbal orbiting kerbin and the timer is already counting down

<snip>

That's really tricky. You'd want to use the NewVessel parameter that Nori suggested, as well as using vessel defines and the IsNotVessel similar to this contract. Even then, I don't think I have anything that would require 3 different kerbals, unless you require all three ships to be crewed and in orbit at the same time (although I suspect you didn't mean simultaneously).

Link to comment
Share on other sites

While, I'm reluctant to report an issue due to your every ten millisecond release schedule. =O I accidentally discovered the contract configurator master control panel and I discovered that it only loaded 28 of 75 contracts, the major failures were Advanced Progression and Base Construction.

I think I figured out how to read these debug logs, it looks like the contract is configured correctly and "Kerbin World-Firsts Record-Keeping Society" is a stock agency, but it is not being parsed. =\

Link to comment
Share on other sites

While, I'm reluctant to report an issue due to your every ten millisecond release schedule. =O I accidentally discovered the contract configurator master control panel and I discovered that it only loaded 28 of 75 contracts, the major failures were Advanced Progression and Base Construction.

I think I figured out how to read these debug logs, it looks like the contract is configured correctly and "Kerbin World-Firsts Record-Keeping Society" is a stock agency, but it is not being parsed. =\

Hmm, I'm thinking install issues are at fault. I use or have used both of those mods and I do not see any loading failures. Try deleting the ContractPacks and Contract Configurator folders and redownloading/installing.

Link to comment
Share on other sites

I found the problem with Base Construction, it was a leftover fragment of Remote Tech (a handful of parts I still needed). Anyway, here's the exception it wants me to report:

[WRN 18:25:46.398] ContractConfigurator.ConfiguredContract: Error loading contract for contract type 'KerbinStationCore'. The contract type either failed to load or was uninstalled.

[WRN 18:25:46.399] ContractConfigurator.ConfiguredContract: Error loading contract for contract type 'KerbinStationCore'. The contract type either failed to load or was uninstalled.

[EXC 18:25:46.408] ArgumentException: Missing required value 'biome'.

ContractConfigurator.ConfigNodeUtil.ParseValue[string] (.ConfigNode configNode, System.String key, Boolean allowExpression)

ContractConfigurator.Parameters.ReachState.OnParameterLoad (.ConfigNode node)

ContractConfigurator.Parameters.ContractConfiguratorParameter.OnLoad (.ConfigNode node)

UnityEngine.Debug:LogException(Exception)

ContractConfigurator.LoggingUtil:LogException(Exception)

ContractConfigurator.Parameters.ContractConfiguratorParameter:OnLoad(ConfigNode)

Contracts.ContractParameter:Load(ConfigNode)

Contracts.ContractParameter:Load(ConfigNode)

Contracts.Contract:Load(Contract, ConfigNode)

Contracts.ContractSystem:LoadContract(ConfigNode)

Contracts.

:MoveNext()

[LOG 18:25:46.425] Contracts Loaded

[LOG 18:25:46.426] PARAM

{

name = PartRequestParameter

state = Incomplete

values = 0,0,0,0,0

title = Have a research lab at the station

partNames = Large_Crewed_Lab,StnSciLab,StnSciZoo

moduleNames = ModuleScienceLab

}

[LOG 18:25:46.427] PARAM Large_Crewed_Lab,StnSciLab,StnSciZoo

[LOG 18:25:46.427] PARAM

{

name = PartRequestParameter

state = Incomplete

values = 0,0,0,0,0

title = Have a viewing cupola at the station

partNames = cupola

moduleNames =

}

[LOG 18:25:46.427] PARAM cupola

[LOG 18:26:01.603] [sCANsat] Height Map Of [Kerbin] Completed...

###### AND #####

[EXC 18:29:37.005] NullReferenceException: Object reference not set to an instance of an object

ContractConfigurator.Parameters.ReachState.OnParameterSave (.ConfigNode node)

ContractConfigurator.Parameters.ContractConfiguratorParameter.OnSave (.ConfigNode node)

UnityEngine.Debug:LogException(Exception)

ContractConfigurator.LoggingUtil:LogException(Exception)

ContractConfigurator.Parameters.ContractConfiguratorParameter:OnSave(ConfigNode)

Contracts.ContractParameter:Save(ConfigNode)

Contracts.ContractParameter:Save(ConfigNode)

Contracts.Contract:Save(ConfigNode)

ContractConfigurator.ContractPreLoader:OnSave(ConfigNode)

ScenarioModule:Save(ConfigNode)

ProtoScenarioModule:.ctor(ScenarioModule)

ScenarioRunner:GetUpdatedProtoModules()

Game:Updated()

GamePersistence:SaveGame(String, String, SaveMode)

SpaceTracking:BoardVessel(Vessel)

SpaceTracking:flySelectedVessel()

ScreenSafeUIButton:OnMouseUp(Boolean)

ScreenSafeUIButton:OnMouseUp()

SSUICamera:DoMouseEvents()

SSUICamera:Update()

[LOG 18:29:37.864] Game State Saved to saves/AlonzoTG/persistent

Link to comment
Share on other sites

I found the problem with Base Construction, it was a leftover fragment of Remote Tech (a handful of parts I still needed). Anyway, here's the exception it wants me to report:

<snip>

Any chance you uninstalled a planet pack? That's the only reason I can think of that would cause that. Regardless, fixed for the next release.

You may need to do some save hacking and remove the contract in question to get things going again in the meantime.

Link to comment
Share on other sites

Quick question. I have the Asclepius, SCANSat, Kerbin Space Station, RemoteTech, and Tourism contract packs installed, but only Kerbin Space Station is showing up as a deselectable option when I click on the button in the toolbar - I have no indication the others are working. Is everything working as intended? Should I specifically complain to the authors of the specific contract packs?

EDIT: Removing a lot of mods fixed the issue. Stand by for me figuring out what went wrong.

EDIT 2: I seem to have discovered an incompatibility of some sort. Stand by.

Edited by Whovian
Link to comment
Share on other sites

Put in the red text in that group.

Three orbits meaning orbit around the planet 3 times?

You could easily extend the duration.

If you instead mean you need to complete that contract 3 times then it can be done, but is more complicated.

Likewise your 3rd request is possible using behaviors so check that section out on the docs.

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

Thank you Nori, I will try the new vessel parameter addition out later today... My original Idea was I wanted this contract to be completed 3 separate times, I tried having Minimum completions =3 But that didn't work out.

It is probably possible to work around this by just adding 2 more vessels that need to be in orbit for the 40 minutes, but if it is possible to have the same contract offered/completed 3 times before unlocking the next contract in the list, I'd want to see how this could be done.

I am using a contract originally made by Seti so I don't completely understand behaviors and expressions. I don't know where and how the behaviors that seti used were defined, I just know they existed and are used to be sure that contracts unlock in a certain order.

I'd love to see custom made examples of some expressions and behaviors, I know you mentioned I could have 3 different kerbals attain orbit in the same contract using behaviors

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

I have tried to download a copy of the docs to my computer so I could read them, but "github" is not letting me clone the .zip to the desktop, I knew some other mods had an easy download source code option that made it very easy to get to the documentation, is there a non github way to get the documentation for contract configurator

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

Thanks nightingale for linking in that comsat network contract, it helped me see how to have multiple vessel parameter groups in the same contract, though I don't quite understand what you mean by "vessel defines" in your post.

Edited by ToneStack
Link to comment
Share on other sites

Quick question. I have the Asclepius, SCANSat, Kerbin Space Station, RemoteTech, and Tourism contract packs installed, but only Kerbin Space Station is showing up as a deselectable option when I click on the button in the toolbar - I have no indication the others are working. Is everything working as intended? Should I specifically complain to the authors of the specific contract packs?

EDIT: Removing a lot of mods fixed the issue. Stand by for me figuring out what went wrong.

EDIT 2: I seem to have discovered an incompatibility of some sort. Stand by.

99% certain it's an agent loading issue. Check the log file - you'll find there's an agent that's failing to load, and that stops all other agents from loading, which stops the contracts from loading. I've heard of this happening when installing Texture Replacer, or if you tried to do a manual DDS conversion. For the first issue, I hear installing ATM fixes it, the latter your best bet is to convert the file in question back to PNG.

- - - Updated - - -

I have tried to download a copy of the docs to my computer so I could read them, but "github" is not letting me clone the .zip to the desktop, I knew some other mods had an easy download source code option that made it very easy to get to the documentation, is there a non github way to get the documentation for contract configurator

There isn't one. You can do a git pull of the wiki site, but otherwise there's no way to download the docs that I'm aware of.

Thanks nightingale for linking in that comsat network contract, it helped me see how to have multiple vessel parameter groups in the same contract, though I don't quite understand what you mean by "vessel defines" in your post.

See the define attribute of VesselParameterGroup.

Link to comment
Share on other sites

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

Thank you Nori, I will try the new vessel parameter addition out later today... My original Idea was I wanted this contract to be completed 3 separate times, I tried having Minimum completions =3 But that didn't work out.

It is probably possible to work around this by just adding 2 more vessels that need to be in orbit for the 40 minutes, but if it is possible to have the same contract offered/completed 3 times before unlocking the next contract in the list, I'd want to see how this could be done.

I am using a contract originally made by Seti so I don't completely understand behaviors and expressions. I don't know where and how the behaviors that seti used were defined, I just know they existed and are used to be sure that contracts unlock in a certain order.

I'd love to see custom made examples of some expressions and behaviors, I know you mentioned I could have 3 different kerbals attain orbit in the same contract using behaviors

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

I have tried to download a copy of the docs to my computer so I could read them, but "github" is not letting me clone the .zip to the desktop, I knew some other mods had an easy download source code option that made it very easy to get to the documentation, is there a non github way to get the documentation for contract configurator

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

Thanks nightingale for linking in that comsat network contract, it helped me see how to have multiple vessel parameter groups in the same contract, though I don't quite understand what you mean by "vessel defines" in your post.

This might work. I changed the behavior to add 5 each time the contract is completed. It allows 2 to be completed with would add up to 10. From what I can tell it has to equal 10 exactly. So it'd be best to have it be either 2 or 4 completions for simplicity.

Also added the new vessel parameter.


//---Manned Orbit---\\

CONTRACT_TYPE
{
name = MannedOrbit

title = Manned Orbit and safe return!
description = While reaching orbit with a probe was quite an accomplishment, sending a kerbal up there will be great inspiration for kerbalkind and thus an important milestone for our space program.
synopsis = We want you to launch a kerbal into an orbit around Kerbin and then return him safely.
completedMessage = You have successfully completed the first manned orbital mission around Kerbin.

agent = Space Exploration & Technology Initiative

minExpiry = 852.0
maxExpiry = 852.0

cancellable = true
declinable = true

prestige = Significant

targetBody = Kerbin

maxCompletions = 2
maxSimultaneous = 1

rewardScience = 18.0
rewardReputation = 80.0
rewardFunds = 72000.0
failureFunds = 24000.0
advanceFunds = 24000.0


PARAMETER
{
name = OrbitKerbin
type = VesselParameterGroup

PARAMETER
{
name = NewVessel
type = NewVessel
}

PARAMETER
{
name = HasCrew
type = HasCrew

minCrew = 1
}

PARAMETER
{
name = ReachState
type = ReachState

situation = ORBITING
disableOnStateChange = true
}

PARAMETER
{
name = ReturnHome
type = ReturnHome
}
}

BEHAVIOUR
{
name = Progression
type = Expression

CONTRACT_COMPLETED_SUCCESS
{
setiMannedOrbit + 5
}
}

REQUIREMENT
{
name = All
type = All

REQUIREMENT
{
name = Progression
type = Expression

expression = setiMannedAltitude18km == 10
}
REQUIREMENT
{
name = Progression
type = Expression

expression = setiOrbitRecovery == 10
}
}
}

Link to comment
Share on other sites

99% certain it's an agent loading issue. Check the log file - you'll find there's an agent that's failing to load, and that stops all other agents from loading, which stops the contracts from loading. I've heard of this happening when installing Texture Replacer, or if you tried to do a manual DDS conversion. For the first issue, I hear installing ATM fixes it, the latter your best bet is to convert the file in question back to PNG.

Yep, the culprit was Texture Replacer. Any alternate fixes? I have humongous textures and would rather not wait for 4 hours for KSP to start up with ATM. I've tried marking the agency textures for not-unloading and disabling unloading altogether to no avail.

EDIT: I'm trying to comment out the agency from all the contract cfg files.

EDIT 2: That ... did not work; now it's complaining that "'Research & Development Department' is not a valid agent," despite the fact that I've no idea where it got the phrase "Research & Development Department."

Edited by Whovian
Link to comment
Share on other sites

Yep, the culprit was Texture Replacer. Any alternate fixes? I have humongous textures and would rather not wait for 4 hours for KSP to start up with ATM. I've tried marking the agency textures for not-unloading and disabling unloading altogether to no avail.

EDIT: I'm trying to comment out the agency from all the contract cfg files.

Post a KSP.log for me. If we can find out which texture is the one that's failing, we can create a scaled version of the logo. Then KSP will no longer try to read the texture that Texture Replacer made unreadable. I can submit the fix back to whichever mod is causing the trouble, and we can all be happy. :)

Link to comment
Share on other sites

Can't post the whole log since it's too long for even Pastebin, but here's the Contract Configurator bit:

http://pastebin.com/mqMCj07G

EDIT: It's also not /just/ Texture Replacer, as I ran Texture Replacer and Contract Configurator with almost nothing else just fine; something's triggering it to be all wonky. Not sure exactly what, though.

Link to comment
Share on other sites

Can't post the whole log since it's too long for even Pastebin, but here's the Contract Configurator bit:

http://pastebin.com/mqMCj07G

EDIT: It's also not /just/ Texture Replacer, as I ran Texture Replacer and Contract Configurator with almost nothing else just fine; something's triggering it to be all wonky. Not sure exactly what, though.

The part I need is before that. Just search for the first EXC tag or two, should be something related to agents. Or post on dropbox/google drive.

EDIT: the something else is the mod that is introducing an unscaled flag. It's actually just that + Texture Replacer that cause the problem, and Contract Configurator is caught in the crossfire.

Edited by nightingale
Link to comment
Share on other sites

Ah.

[EXC 18:09:45.367] UnityException: Texture 'BAE/Agencies/behemoth' is not readable, the texture memory can not be accessed from scripts. You can make the texture readable in the Texture Import Settings.

That would be Behemoth Aerospace Engineering. Hence the conflict was a 3-way (between Texture Replacer, CC, and BAE), which would explain why I was having so much trouble finding it.

Although I'm surprised BAE is the only problem; if there are multiple issues will only one throw an exception?

EDIT: Yep, removing BAE fixed the issue. Thanks!

Edited by Whovian
Link to comment
Share on other sites

I'm having some odd behavior (or behaviour as the mod insists I spell it :D) with this bit of code:


PARAMETER
{
type = All
title = Get In the car, to recover it.
PARAMETER
{
type = ReachState
targetBody = Kerbin
situation = LANDED
}
PARAMETER
{
type = HasCrew
minCrew = 1
}
PARAMETER
{
type = PartValidation
part = GrapplingDevice
}
}

The way I read that, the parameter should not complete until I have a vessel that is landed on Kerbin, with a claw, and has at least 1 Kerbal on it. Note: This is part of a SpawnVessel contract that spawns an unmanned but mannable vessel with a claw on it. My idea is you have to get to this vessel and get inside to complete the contract. Everything works fine if you actually follow the rules: Fly a ship to the vessel. Land. Get out. Walk over. Get in the new vessel. The parameter completes correctly.

However, if you just fly your vessel near the target vessel, land, and then use [ or ] to switch vehicles, the contract ALSO completes. It's as if it's remembering that there was a Kerbal in the other vessel, so it "counts" that Kerbal as being in the new vessel.

The target vessel happens to be near the KSC, so I can actually "Fly" it from there without launching a ship. If I do so, it fails the contract. So, I'm sure the problem is specific to sending out a crewed vessel and not something odd with the craft file.

I can provide more if needed, or put in a proper bug report if this sounds more like a bug than a "you're doing it wrong." :)

Link to comment
Share on other sites

One more question and then I'm off to bed for the day:

I'm trying to use a list to select a part to spawn, require for contract completion, and reward to the player. I'm not 100% sure this is the way to go but I'm trying to burn each bridge as I come to it.

This code does not work:


DATA
{
type = AvailablePart
partToScavenge = [ fuelTankSmallFlat , liquidEngine ].Random()
}

Either of these, though, works fine:


DATA
{
type = AvailablePart
partToScavenge = fuelTankSmallFlat
}
or
DATA
{
type = AvailablePart
partToScavenge = liquidEngine
}

So what am I doing wrong with the list, and how can I do it more correctly?

Bonus points for a way to select only the part(s) from the list that are not already in the list of experimental parts the player has access to.

Edited by 5thHorseman
Link to comment
Share on other sites

I'm having some odd behavior (or behaviour as the mod insists I spell it :D) with this bit of code:


PARAMETER
{
type = All
title = Get In the car, to recover it.
PARAMETER
{
type = ReachState
targetBody = Kerbin
situation = LANDED
}
PARAMETER
{
type = HasCrew
minCrew = 1
}
PARAMETER
{
type = PartValidation
part = GrapplingDevice
}
}

<snip>

The All parameter just means, "complete all these things". Individually, a parameter will complete (and stay complete depending on its default settings or how you've set the disableOnStateChange attribute). The recommended way to do it is to use VesselParameterGroup instead of All. It's very special, as it tracks the values of its child parameters on an individual vessel basis, and won't complete until there is one vessel that meets all criteria.

- - - Updated - - -

One more question and then I'm off to bed for the day:

I'm trying to use a list to select a part to spawn, require for contract completion, and reward to the player. I'm not 100% sure this is the way to go but I'm trying to burn each bridge as I come to it.

This code does not work:


DATA
{
type = AvailablePart
partToScavenge = [ fuelTankSmallFlat , liquidEngine ].Random()
}

I won't have access to KSP for about 24 hours, so I can't test this myself, but it's supposed to work. Maybe file a GitHub report and I'll look at it tomorrow. If I had to take a guess, maybe it's not parsing the list properly, and will work if you split into two steps:


DATA
{
type = List<AvailablePart>
partsToScavenge = [ fuelTankSmallFlat , liquidEngine ]
}
DATA
{
type = AvailablePart
partToScavenge = @partsToScavenge.Random()
}

Either of these, though, works fine:


DATA
{
type = AvailablePart
partToScavenge = fuelTankSmallFlat
}
or
DATA
{
type = AvailablePart
partToScavenge = liquidEngine
}

So what am I doing wrong with the list, and how can I do it more correctly?

Bonus points for a way to select only the part(s) from the list that are not already in the list of experimental parts the player has access to.


DATA
{
type = List<AvailablePart>
allLockedParts = [COLOR=#333333][FONT=Consolas]AllParts().Where(p => !p.[/FONT][/COLOR][COLOR=#333333][FONT=Consolas]IsUnlocked())[/FONT][/COLOR]
}

Link to comment
Share on other sites

I'm having some odd behavior (or behaviour as the mod insists I spell it :D) with this bit of code:


PARAMETER
{
type = All
title = Get In the car, to recover it.
PARAMETER
blablablabla

The way I read that, the parameter should not complete until I have a vessel that is landed on Kerbin, with a claw, and has at least 1 Kerbal on it. Note: This is part of a SpawnVessel contract that spawns an unmanned but mannable vessel with a claw on it. My idea is you have to get to this vessel and get inside to complete the contract. Everything works fine if you actually follow the rules: Fly a ship to the vessel. Land. Get out. Walk over. Get in the new vessel. The parameter completes correctly.

However, if you just fly your vessel near the target vessel, land, and then use [ or ] to switch vehicles, the contract ALSO completes. It's as if it's remembering that there was a Kerbal in the other vessel, so it "counts" that Kerbal as being in the new vessel.

The target vessel happens to be near the KSC, so I can actually "Fly" it from there without launching a ship. If I do so, it fails the contract. So, I'm sure the problem is specific to sending out a crewed vessel and not something odd with the craft file.

I can provide more if needed, or put in a proper bug report if this sounds more like a bug than a "you're doing it wrong." :)

I think you want to do type = VesselParameterGroup instead of type = All

here's an example from my Asclepius contract pack (spawns a vessel landed @asclepius, requires that you land the vessel on kerbin, not destroyed)


// Requires Contract Configurator. Forum link http://forum.kerbalspaceprogram.com/threads/101604
// Adds a Contract to recover a prebuilt SSTO spaceplane from Asclepius, and return it to kerbin.
// By MrChumley

CONTRACT_TYPE
{
name = RescueGooba
group = Far Out
title = Return Superplane to Kerbin
description = Gooba Kerman has lost a pilot in a tragic rover accident, and needs a new pilot to fly his Superplane back home to Kerbin. He says the engines should work with actiongroups. This is where you come in.

synopsis = Land Gooba's Superplane on Kerbin
completedMessage = Congratulations! Gooba is pleased.
agent = Far Out Enterprises
targetBody = Asclepius
rewardScience = 55.0
rewardReputation = 10.0
rewardFunds = 180000.0
failureReputation = 3.0
failureFunds = 50.0
weight = 99.0
minExpiry = 0.0
maxExpiry = 0.0
autoAccept = false
maxCompletions = 1
maxSimultaneous = 1

REQUIREMENT
{
name = Orbit
type = Orbit
targetBody = Asclepius
}

BEHAVIOUR
{
name = WaypointGenerator
type = WaypointGenerator

WAYPOINT
{
name = Gooba
targetBody = Asclepius
icon = balloon
altitude = 0.0
// The coordinates.
latitude = 27.6062949241042
longitude = 377.095175020215
}
}

PARAMETER
{
name = FindGooba
type = VisitWaypoint
distance = 1000
title = Gooba needs your help!
hideOnCompletion = true
disableOnStateChange = true
optional = true
}

BEHAVIOUR
{
name = ChangeVesselOwnership
type = ChangeVesselOwnership
onState = ParameterCompleted
parameter = FindGooba
vessel = Goobs Superplane
owned = true
}

PARAMETER
{
name = VesselParameterGroup
type = VesselParameterGroup
vessel = Goobs Superplane

PARAMETER
{
name = ReachState
type = ReachState
targetBody = Kerbin
situation = LANDED
title = Land on Kerbin!
}

PARAMETER
{
name = VesselNotDestroyed
type = VesselNotDestroyed

vessel = Goobs Superplane
}
}

BEHAVIOUR
{
name = SpawnVessel
type = SpawnVessel


VESSEL
{
name = Goobs Superplane
craftURL = ContractPacks/AscContract/Ships/SPH/Superplane.craft
flagURL = ContractPacks/AscContract/Flags/swirly.png
owned = False
targetBody = Asclepius
lat = 27.6062949241042
lon = 377.095175020215
heading = 90.0
CREW
{
name = Gooba Kerman
addToRoster = True
}
}
}
}

Link to comment
Share on other sites

Thank you both. I misread "all" as "all must be completed." VesselParameterGroup worked perfectly, and actually ended up being much cleaner due to being able to tie it directly to the vessel.

I won't have access to KSP for about 24 hours, so I can't test this myself, but it's supposed to work. Maybe file a GitHub report and I'll look at it tomorrow. If I had to take a guess, maybe it's not parsing the list properly, and will work if you split into two steps:


DATA
{
type = List<AvailablePart>
partsToScavenge = [ fuelTankSmallFlat , liquidEngine ]
}
DATA
{
type = AvailablePart
partToScavenge = @partsToScavenge.Random()
}

Yeah there does seem to be something wrong. I'll open a gitHub issue for it but when I do anything other than partsToScavenge = fuelTankSmallFlat (i.e., just specify a part) I get the error in the log, "System.ArguementException: 'fuelTankSmallFlat' is not a valid Part."

But, like I said, if I set it directly (no list, random, or anything else tricky) it works fine, so it's obviously a valid Part.


DATA
{
type = List<AvailablePart>
allLockedParts = [COLOR=#333333][FONT=Consolas]AllParts().Where(p => !p.[/FONT][/COLOR][COLOR=#333333][FONT=Consolas]IsUnlocked())[/FONT][/COLOR]
}

So if I'm reading this right, would this only pull a locked part from my list (once the above problem is resolved)?


DATA
{
type = AvailablePart
partToScavenge = [ fuelTankSmallFlat , liquidEngine ].Where(p => !p.IsUnlocked()).Random()
}

- - - Updated - - -

I GOT IT. WOO HOO GO ME

The list can't have spaces after the part name, or the spaces get counted as part of the name. So [ fuelTankSmallFlat , liquidEngine ] fails but [ fuelTankSmallFlat, liquidEngine] works like a charm.

GitHub issue reported.

Edited by 5thHorseman
Link to comment
Share on other sites

I GOT IT. WOO HOO GO ME

The list can't have spaces after the part name, or the spaces get counted as part of the name. So [ fuelTankSmallFlat , liquidEngine ] fails but [ fuelTankSmallFlat, liquidEngine] works like a charm.

GitHub issue reported.

Oooh, that's tricksey. There's a reason I don't having to support spaces as part of identifiers, but Kerbal Names, Vessel Names, Parts and other things forced me into it. Anyway, easy enough fix - just need to strip those trailing spaces.

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