jrossignol / ContractConfigurator

A config file based solution for creating new contracts for Kerbal Space Program.
https://forum.kerbalspaceprogram.com/index.php?/topic/91625-1
Other
64 stars 67 forks source link

ArgumentException: Must be greater than 3500 #515

Closed linuxgurugamer closed 8 years ago

linuxgurugamer commented 8 years ago

Here is the error (contract below):

ContractConfigurator.Behaviour.WaypointGeneratorFactory: CONTRACT_TYPE 'RoverExplore', BEHAVIOUR '@/a1' of type 'WaypointGenerator: A validation error occured while loading the key 'maxDistance' with value '3000'.
ArgumentException: Must be greater than 3500
  at ContractConfigurator.Validation.GT[Double] (Double val, Double referenceValue) [0x00000] in <filename unknown>:0 
  at ContractConfigurator.Behaviour.WaypointGenerator+<>c__DisplayClass8_0.<Create>b__25 (Double x) [0x00000] in <filename unknown>:0 
  at ContractConfigurator.ConfigNodeUtil.ParseValue[Double] (.ConfigNode configNode, System.String key, System.Action`1 setter, IContractConfiguratorFactory obj, Double defaultValue, System.Func`2 validation) [0x00000] in <filename unknown>:0 
UnityEngine.Debug:Internal_LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
ContractConfigurator.LoggingUtil:LogException(Exception)
ContractConfigurator.ConfigNodeUtil:ParseValue(ConfigNode, String, Action`1, IContractConfiguratorFactory, Double, Func`2)
ContractConfigurator.ConfigNodeUtil:ParseValue(ConfigNode, String, Action`1, IContractConfiguratorFactory, Func`2)
ContractConfigurator.DeferredLoadUtil:ExecuteLoad(DeferredLoadObject`1)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
ContractConfigurator.<UpdateNonDeterministicValuesIterator>d__26:MoveNext()
System.Linq.<CreateConcatIterator>c__Iterator1`1:MoveNext()
ContractConfigurator.<ContractGenerator>d__26:MoveNext()
ContractConfigurator.<ContractGenerator>d__25:MoveNext()
ContractConfigurator.ContractPreLoader:Update()`
jrossignol commented 8 years ago

Wrong contract - I need the RoverExplore one. On May 18, 2016 5:40 AM, "linuxgurugamer" notifications@github.com wrote:

Here is the error (contract below): `ContractConfigurator.Behaviour.WaypointGeneratorFactory: CONTRACT_TYPE 'RoverExplore', BEHAVIOUR '@/a1' of type 'WaypointGenerator: A validation error occured while loading the key 'maxDistance' with value '3000'.

(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)

ArgumentException: Must be greater than 3500 at ContractConfigurator.Validation.GTDouble http://Double%20val,%20Double%20referenceValue [0x00000] in :0

at ContractConfigurator.Behaviour.WaypointGenerator+<>c__DisplayClass8_0.b__25 (Double x) [0x00000] in :0

at ContractConfigurator.ConfigNodeUtil.ParseValueDouble [0x00000] in :0 UnityEngine.Debug:Internal_LogException(Exception, Object) UnityEngine.Debug:LogException(Exception) ContractConfigurator.LoggingUtil:LogException(Exception) ContractConfigurator.ConfigNodeUtil:ParseValue(ConfigNode, String, Action1, IContractConfiguratorFactory, Double, Func2) ContractConfigurator.ConfigNodeUtil:ParseValue(ConfigNode, String, Action1, IContractConfiguratorFactory, Func2) ContractConfigurator.DeferredLoadUtil:ExecuteLoad(DeferredLoadObject1) System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&) System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) System.Reflection.MethodBase:Invoke(Object, Object[]) ContractConfigurator.d26:MoveNext() System.Linq.cIterator11:MoveNext() ContractConfigurator.d26:MoveNext() ContractConfigurator.d25:MoveNext() ContractConfigurator.ContractPreLoader:Update()`

Here is the contract: `// Requires version 1.9.3

CONTRACT_TYPE { name = RoverDeploy title = Rover Deployment group = SpaceTuxGroup agent = Space Penguins, Inc

description = Much of @/targetBody is a mystery to us still. We could learn a lot by deploying a new rover there. notes = Launch a new rover to @/targetBody. Include all the scientific instrumentation you can! synopsis = Launch a new rover to @/targetBody completedMessage = The rover is on location and ready for research! deadline = 10000 targetBody = @/planet maxSimultaneous = 1 rewardReputation = 2 rewardFunds = 10000 failureReputation = 4 failureFunds = 20000 advanceFunds = 10000 weight = 5.0

BEHAVIOUR { name = Expression type = Expression

CONTRACT_COMPLETED_SUCCESS
{
    type = bool
    RC_roverDeployed = true
}

}

// BEHAVIOUR:NEEDS[UnmannedContracts] // { // name = DialogBox // type = DialogBox // // DIALOG_BOX // { // title = test dialog box // condition = CONTRACT_ACCEPTED // TEXT // { // text = Unmanned Contracts detected // } // } // }

DATA { type = CelestialBody planet = Prestige() == Trivial ? @/easyPlanets.Random() : Prestige() == Significant ? @/mediumPlanets.Random() : @/hardPlanets.Random() }

DATA { type = CelestialBody kerbin = Kerbin mun = Mun minmus = Minmus duna = Duna

}

DATA { type = bool moonsReached = @mun.HaveReached() || @minmus.HaveReached() dunaReached = @duna.HaveReached() }

DATA { type = List // Make sure first rover is deployed to Kerbin easyPlanets = bool($RC_roverDeployed) ? HomeWorld().Children() : [ @kerbin ]

// First line:  get planets depending on orbited or not
// Second line: get planets depending on if any rovers or not
mediumPlanets1 =  OrbitedBodies().Where(b => b.HasSurface()).ExcludeAll(@easyPlanets).Exclude(HomeWorld())
mediumPlanets2 =  @dunaReached ? @mediumPlanets1 : @easyPlanets
mediumPlanets3 = @mediumPlanets2.Count() > 0 ? @mediumPlanets2 : [@kerbin]
mediumPlanets =  bool($RC_roverDeployed)  ? @mediumPlanets3 : [ @kerbin ]

hardPlanetsTemp =  @dunaReached  ?AllBodies().Where(b => b.HasSurface()).ExcludeAll(@easyPlanets) : [ @kerbin ]
hardPlanetsTemp1 = @hardPlanetsTemp.Count() > 0 ? @hardPlanetsTemp : [ @kerbin ]
hardPlanetsTemp2 = @dunaReached ?  @hardPlanetsTemp1.ExcludeAll(@mediumPlanets).Exclude(HomeWorld()) : @mediumPlanets
hardPlanetsTemp3 = @hardPlanetsTemp2.Count() > 0 ? @hardPlanetsTemp2 : @mediumPlanets
hardPlanets =  bool($RC_roverDeployed) ? @hardPlanetsTemp3 : [ @kerbin ]

}

REQUIREMENT { name = PartModuleTypeUnlocked type = PartModuleTypeUnlocked partModuleType = Antenna partModuleType = Wheel }

PARAMETER { name = NewVessel type = NewVessel title = Launch a new rover }

PARAMETER { name = ReachState type = ReachState situation = LANDED }

PARAMETER { name = VesselIsType type = VesselIsType vesselType = Rover title = Set vessel type to Rover }

}`

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/jrossignol/ContractConfigurator/issues/515

linuxgurugamer commented 8 years ago
CONTRACT_TYPE
{
    name = RoverExplore
    title = Rover Expedition
    group = SpaceTuxGroup

    description = The science team has identified an area of scientific interest and believes that @/targetVessel on @/targetBody should be directed to investigate.
    notes = Pilot your rover to the indicated location and perform all the science you can at that site.
    synopsis = Drive @/targetVessel on @/targetBody to this location.
    completedMessage = Research complete!  Good work.
    deadline = 50
    targetBody = @/targetVessel.CelestialBody()
    maxSimultaneous = 1
    rewardReputation = 1.0
    rewardFunds = 10000.0
    failureReputation = 5.0
    failureFunds = 20000.0
    advanceFunds = 0

    agent = Space Penguins, Inc

    weight = 15.0

    DATA
    {
        type = Vessel
        requiredValue = true
        targetVessel = AllVessels().Where(v => v.VesselType() == Rover && v.IsLanded() == true).Random()
    }

    DATA
    {
        type = double
        targetRadius = @/targetBody.Radius()
        homeRadius = HomeWorld().Radius()
        distanceFactorTemp = @targetRadius == 0 ? 1 : @targetRadius/@homeRadius + 0.3
        distanceFactor = @distanceFactorTemp / 2
// Following for testing only
//distanceFactor = 0.1

        TrivialMin = 3000 * @distanceFactor
        SignificantMin = 5000 * @distanceFactor
        ExceptionalMin = 7000 * @distanceFactor
        TrivialMax = 4000 * @distanceFactor
        SignificantMax = 6000 * @distanceFactor
        ExceptionalMax = 8000 * @distanceFactor
    }

    DATA
    {
        type = bool
        isTrivial = Prestige() == Trivial
        isSignificant = Prestige() == Significant
        isExceptional = Prestige() == Exceptional
        hasTherm = @/targetVessel.Parts().Where(p => p == sensorThermometer).Count() > 0
        hasBar = @/targetVessel.Parts().Where(p => p == sensorBarometer).Count() > 0
        hasAccel = @/targetVessel.Parts().Where(p => p == sensorAccelerometer).Count() > 0
        hasGrav = @/targetVessel.Parts().Where(p => p == sensorGravimeter).Count() > 0
        hasGoo = @/targetVessel.Parts().Where(p => p == GooExperiment).Count() > 0
        hasMat = @/targetVessel.Parts().Where(p => p == science_module).Count() > 0
        hasAtmo = @/targetVessel.Parts().Where(p => p == sensorAtmosphere).Count() > 0
        hasScientist = @/targetVessel.Crew().Where(k => k.ExperienceTrait() == "Scientist").Count() > 0
        hasAtmosphere = @/targetBody.HasAtmosphere()

// Following have not yet been implemented
//
// name
// title
// experiment

// dmAnomScanner
// Anomalous Signal Sensor
// AnomalyScan
// 
// dmDAN
// Dynamic Albedo of Neutrons
// dmNAlbedoScan
// 
// dmbioDrill
// ExoKerbol Core Drill
// dmbiodrillscan
// 
// sensorGravimeter
// GRAVMAX Negative Gravioli Detector
// gravityScan
// 
// dmRoverGoo
// Micro Goo Containment Pod
// mysteryGoo
// 
// dmRoverMat
// SC-901 Science Micro
// mobileMaterialsLab
// 
// SCANsat_Scanner32
// SCAN Been There Done That
// no experiment id listed
// 
// dmsurfacelaser
// Surface Ablation Laser Light Imager
// dmlaserblastscan
// 
// SurfaceScanner
// Surface Scanning Module
// no experiment id listed
// 
// dmXRay
// XRD Surface Analyzer
// dmXRayDiffract
// 

    }
    DATA
    {
        type = int
        numWaypoints = Random(1, 5)
// Following for testing only
//numWaypoints = 3
        calcMinCrew = @/targetVessel.CrewCapacity() > 0 ? 1:0
    }
    DATA
    {
        type = List<int>
        nums = [0,1,2,3,4]

    }

    DATA
    {
        type = List<string>

        a1l = [ "Marker", "Memorial", "Milestone", "Monument", "Museum", "Tree", "Battleground", "Benchmark", "Bend", "Blaze" ]
        a2l = [ "Geature", "Gragment", "Huide", "Hill", "Mark", "Milepost", "Mountain", "Promontory", "Remnant", "Ruins" ]
        a3l = [ "Souvenir", "Specimen", "Stone", "Survival", "Trace", "Vestige", "Vantage point", "Waypost", "Beacon", "Bellwether" ]
        a4l = [ "Catalog", "Chapter and Verse", "Clue", "Compendium", "Directory", "Enchiridion", "Guiding Light", "Hot Lead", "Key", "Landmark" ]
        a5l = [ "Lodestar", "Manual", "Mark", "Marker", "No-no's", "Pointer", "Sign", "Signal", "Signpost", "Telltale", "Tip-Off", "Vade Mecum" ]

        currentLocs = [ @a1l.Random(), @a1l.Random(), @a1l.Random(), @a1l.Random(), @a1l.Random()]
        kerbals = [ RandomKerbalName(Male),  RandomKerbalName(Female),  RandomKerbalName(Male),  RandomKerbalName(Female),  RandomKerbalName(Female)]
// Following for testing only
//currentLocs = ["one", "two", "three", "four", "five"]
//kerbals = "K1 K1", "K2 K2", "K3 K3", "K4 K4", "K5 K5"]
    }
    DATA
    {
        type = string

        a1 = @currentLocs.ElementAt(0)
        a2 = @currentLocs.ElementAt(1)
        a3 = @currentLocs.ElementAt(2)
        a4 = @currentLocs.ElementAt(3)
        a5 = @currentLocs.ElementAt(4)
    }

    PARAMETER
    {
        name = HasCrew
        type = HasCrew
        //minCrew = @/targetVessel.CrewCapacity() 
        minCrew = @/calcMinCrew
        REQUIREMENT
        {
            name = crewRequirement
            type = Expression
            expression = @/calcMinCrew > 0
        }
    }
    PARAMETER
    {
        name = PartValidation
        type = PartValidation

        partModule = ModuleWheel
    }

    PARAMETER
    {
        name = Sequence1
        type = Sequence

        completeInSequence = true

        hiddenParameter = PARAM_1
        hiddenParameter = PARAM_2
        hiddenParameter = PARAM_3
        hiddenParameter = PARAM_4

        hiddenParameter = CollectAllScience

        PARAMETER
        {
            name = ReachState
            type = ReachState
            failWhenUnmet = true
            maxTerrainAltitude = 1000
        }

        PARAMETER
        {
            name = PARAM_@id
            type = All

            ITERATOR
            {
                type = int
                id = @/nums.Where(i => i <@/numWaypoints)
            }

            PARAMETER
            {
                name = LocationAllObjectives@../id
                type = VesselParameterGroup
                //type = Sequence
                disableOnStateChange = false
                title = Investigate @/currentLocs.ElementAt(@../id)

                PARAMETER
                {
                    index = @../../id + 1
                    //name = Location @/currentLocs.ElementAt(@index) Arrival
                    name = LocationArrival_@index
                    type = VisitWaypoint
                    distance = 500.0
                    hideOnCompletion = true
                    showMessages = true
                    title = Scientist @/kerbals.ElementAt(@index - 1) would like you to go investigate @/currentLocs.ElementAt(@index - 1)
                }
            }
        }

        PARAMETER
        {
            type = Sequence
            name = CollectAllScience
            PARAMETER
            {
                index = @/numWaypoints
                name = Location @/currentLocs.ElementAt(@index) Arrival
                //name = LocationArrival_@index
                type = VisitWaypoint
                distance = 500.0
                hideOnCompletion = true
                showMessages = true
                title = Collect Science at @index
            }
            PARAMETER
            {
                name = VesselParameterGroup
                type = VesselParameterGroup

                PARAMETER
                {
                    name = Location TemperatureScan
                    //name = Location @../../id TemperatureScan
                    //name = Location @../../../id TemperatureScan
                    type = CollectScience
                    experiment = temperatureScan
                //  title = Get the temperature
                //  situation = SrfLanded
                //  location = Surface
                    recoveryMethod = None
                    rewardScience = 0.25

                    REQUIREMENT
                    {
                        name = Location TemperatureScanRequirement
                        //name = Location  @../../../id TemperatureScanRequirement
                        // name = Location  @../../../../id TemperatureScanRequirement
                        type = Expression
                        expression = @/hasTherm
                    }
                }
                PARAMETER
                {
                    name = Location PressureScan
                    //name = Location @../../id PressureScan
                    //name = Location @../../../id PressureScan
                    type = CollectScience
                    experiment = barometerScan
                //  title = Get the atmospheric pressure
                //  situation = SrfLanded
                //  location = Surface
                    recoveryMethod = None
                    rewardScience = 0.25

                    REQUIREMENT
                    {
                        name = Location BarometerScanRequirement
                        //name = Location @../../../id BarometerScanRequirement
                        //name = Location @../../../../id BarometerScanRequirement
                        type = Expression
                        expression = @/hasBar
                    }
                }

                PARAMETER
                {
                    name = Location AccelerometerScan
                    //name = Location @../../id AccelerometerScan
                    //name = Location @../../../id AccelerometerScan
                    type = CollectScience
                    experiment = seismicScan
                //  title = See if the ground is shaking by doing a seismic scan
                //  situation = SrfLanded
                //  location = Surface
                    recoveryMethod = None
                    rewardScience = 0.25

                    REQUIREMENT
                    {
                        name = Location AccelScanRequirement
                        //name = Location @../../../id AccelScanRequirement
                        //name = Location @../../../../id AccelScanRequirement
                        type = Expression
                        expression = @/hasAccel
                    }
                }
                PARAMETER
                {
                    name = Location GravityScan
                    //name = Location @../../id GravityScan
                    //name = Location @../../../id GravityScan
                    type = CollectScience
                    experiment = gravityScan
                //  title = Do a gravity scan to see the local gravity flucuations
                //  situation = SrfLanded
                //  location = Surface
                    recoveryMethod = None
                    rewardScience = 0.25

                    REQUIREMENT
                    {
                        name = Location GravScanRequirement
                        //name = Location @../../../id GravScanRequirement
                        //name = Location @../../../../id GravScanRequirement
                        type = Expression
                        expression = @/hasGrav
                    }
                }

                PARAMETER
                {
                    name = Location CrewReport
                    //name = Location @../../id CrewReport
                    //name = Location @../../../id CrewReport
                    type = CollectScience
                //  title = Get a crew report, eva report and a surface sample
                    experiment = crewReport
                    experiment = evaReport
                    experiment = surfaceSample
                //  situation = SrfLanded
                //  location = Surface
                    recoveryMethod = None
                    rewardScience = 0.5

                    REQUIREMENT
                    {
                        name = Location CrewReportRequirement
                        //name = Location @../../../id CrewReportRequirement
                        //name = Location @../../../../id CrewReportRequirement
                        type = Expression
                        expression = @/hasScientist
                    }
                }
                PARAMETER
                {
                    name = Location Goo
                    //name = Location @../../id Goo
                    //name = Location @../../../id Goo
                    type = CollectScience
                    experiment = mysteryGoo
                //  title = Let's see what the Mystery Goo is doing
                //  situation = SrfLanded
                //  location = Surface
                    recoveryMethod = None
                    rewardScience = 0.5

                    REQUIREMENT
                    {
                        name = Location GooRequirement
                        //name = Location @../../../id GooRequirement
                        //name = Location @../../../../id GooRequirement
                        type = Expression
                        expression = @/hasScientist && @/hasGoo
                    }
                }
                PARAMETER
                {
                    name = Location Mat
                //  name = Location @../../id Mat
                    //name = Location @../../../id Mat
                    type = CollectScience
                    experiment = mobileMaterialsLab
                //  title = Run the experiment in the Mobile Materials Lab
                //  situation = SrfLanded
                //  location = Surface
                    recoveryMethod = None
                    rewardScience = 1.0

                    REQUIREMENT
                    {
                        name = Location MatRequirement
                    //  name = Location @../../../id MatRequirement
                        //name = Location @../../../../id MatRequirement
                        type = Expression
                        expression = @/hasScientist && @/hasMat
                    }
                }

                PARAMETER
                {
                    name = Location AtmoScan
                    //name = Location @../../id AtmoScan
                    //name = Location @../../../id AtmoScan
                    type = CollectScience
                    experiment = atmosphereAnalysis
                //  title = Do an atmospheric analysis
                //  situation = SrfLanded
                //  location = Surface
                    recoveryMethod = None
                    rewardScience = 0.25

                    REQUIREMENT
                    {
                        name = Location AtmoScanRequirement
                        //name = Location @../../../id AtmoScanRequirement
                        //name = Location @../../../../id AtmoScanRequirement
                        type = Expression
                        expression = @/hasAtmo && @/hasAtmosphere
                    }
                }
            }
        }

    }

    BEHAVIOUR
    {
        name = WaypointGenerator
        type = WaypointGenerator

        WAYPOINT
        {
            name = Rover Location 
            hidden = true

            icon = report
            altitude = 0.0
            latitude = @/targetVessel.Location().Latitude()
            longitude = @/targetVessel.Location().Longitude()
        }
        RANDOM_WAYPOINT_NEAR
        {
            name = @/a1
            icon = report

            altitude = 0.0
            waterAllowed = false
            nearIndex = 0
            count = 1
            minDistance = Prestige() == Trivial ? @/TrivialMin : Prestige() == Significant ? @/SignificantMin : @/ExceptionalMin
            maxDistance = Prestige() == Trivial ? @/TrivialMax : Prestige() == Significant ? @/SignificantMax : @/ExceptionalMax
        }
        RANDOM_WAYPOINT_NEAR
        {
            name = @/numWaypoints >=2? @/a2 : "N/A 2"
            icon = report
            hidden = @/numWaypoints < 2

            parameter = PARAM_0

            altitude = 0.0
            waterAllowed = false
            nearIndex = 1
            count = 1
            minDistance = Prestige() == Trivial ? @/TrivialMin : Prestige() == Significant ? @/SignificantMin : @/ExceptionalMin
            maxDistance = Prestige() == Trivial ? @/TrivialMax : Prestige() == Significant ? @/SignificantMax : @/ExceptionalMax
        }
        RANDOM_WAYPOINT_NEAR
        {
            name = @/numWaypoints >=3? @/a3 : "N/A 3"
            icon = report
            hidden = @/numWaypoints < 3

            parameter = PARAM_1

            altitude = 0.0
            waterAllowed = false
            nearIndex = 2
            count = 1
            minDistance = Prestige() == Trivial ? @/TrivialMin : Prestige() == Significant ? @/SignificantMin : @/ExceptionalMin
            maxDistance = Prestige() == Trivial ? @/TrivialMax : Prestige() == Significant ? @/SignificantMax : @/ExceptionalMax
        }
        RANDOM_WAYPOINT_NEAR
        {
            name = @/numWaypoints >=4? @/a4 : "N/A 4"
            icon = report
            hidden = @/numWaypoints < 4

            parameter = PARAM_2

            altitude = 0.0
            waterAllowed = false
            nearIndex = 3
            count = 1
            minDistance = Prestige() == Trivial ? @/TrivialMin : Prestige() == Significant ? @/SignificantMin : @/ExceptionalMin
            maxDistance = Prestige() == Trivial ? @/TrivialMax : Prestige() == Significant ? @/SignificantMax : @/ExceptionalMax
        }
        RANDOM_WAYPOINT_NEAR
        {
            name = @/numWaypoints >=5? @/a5 : "N/A 5"
            icon = report
            hidden = @/numWaypoints < 5

            parameter = PARAM_3

            altitude = 0.0
            waterAllowed = false
            nearIndex = 4
            count = 1
            minDistance = Prestige() == Trivial ? @/TrivialMin : Prestige() == Significant ? @/SignificantMin : @/ExceptionalMin
            maxDistance = Prestige() == Trivial ? @/TrivialMax : Prestige() == Significant ? @/SignificantMax : @/ExceptionalMax
        }

    }
}
jrossignol commented 8 years ago

Fixed for 1.11.6