nightingale

[1.6.x+] Contract Configurator [v1.27.1] [2018-12-28]

Recommended Posts

Snap release to fix it with RemoteTech 1.6 now that it's out. Download it now!

On a slightly different tangent, and hijacking your thread just a itty bitty little bit...

I have a little itch with SCANsat which could be scratched by either sending a patch to the SCANsat and MechJeb guys, running the risk of being not accepted as it is honestly a bit to the side of scope for both of them... Or use my new-found mad C# skillz (thank you CKAN) to write an go-between addon similar to ContractConfigurator.

So, to cut a long story short, I went through the source code, but cannot see how and where in https://github.com/jrossignol/ContractConfigurator/tree/master/source/CC_SCANsat you obtain the reference to the actual SCANdata object. Could you give me a little starting help?

Share this post


Link to post
Share on other sites

Public available API is in SCANUtil, I used SCANUtil.getCoverage that returns only the coverage percentage. That method is new to SCANSat v9.0 so you have to watch for in the dev tree. There is a public static SCANdata getData(CelestialBody body) methode too.

Share this post


Link to post
Share on other sites

Ah, so by using SCANUtil, I don't have to take care of stuff like DLL loading and whatever? Nice, nice, nice... I'll give it a try tonight.

Thank you for the hint :)

Share this post


Link to post
Share on other sites

Looking at the documentation it doesn't seem possible to detect (or have a parameter around) whether a vessel has docked with another or not. Is this right?

On a completely separate issue, where is the best place to make random feature requests? GitHub?

Thanks for a great tool, its finally convinced me to break out my text editor :cool:

Share this post


Link to post
Share on other sites
You actually did it! It works great.

I looked for a "donate" button but couldn't find one :/

Thanks for the thought! No donate button, but the rep button in the forum works for me. ;)

Ah, so by using SCANUtil, I don't have to take care of stuff like DLL loading and whatever? Nice, nice, nice... I'll give it a try tonight.

Thank you for the hint :)

Well, be careful, that's not 100% true. DMagic split out those functions into SCANUtil so you don't have to worry about DLL loading - but that's only if you use reflection. Contract Configurator deals with the DLL dependency issue by isolating the SCANsat integration code into a seperate DLL (CC_SCANsat). If that DLL can't load because SCANsat isn't present... no harm done. I can also get away with this because I don't call anything directly in the CC_SCANsat code from outside).

This is the same way the RemoteTech integration is handled (which is far more complicated, and would be nearly impossible to do with reflection). Also note that RemoteTech is GPL, which is rather restrictive: any code that is linking to GPL code must also be GPL - which is why everything in CC_RemoteTech is licensed GPL - so another bonus of this split.

Anyway, if you want an example of reflection, have a look at this section in ContractConfigurator.cs - it's how I call ModuleManager's reload functions without creating a dependency. It gets ugly pretty fast. If you want an example using SCANsat, poke around the repository for Cyrik's Map Resource Overlay - he should be calling into SCANsat using reflection.

Edited by nightingale
for clarification

Share this post


Link to post
Share on other sites

I think I will be happy for the beginning with SCANutil providing me access to SCANdata.Anomalies

Knowing myself, I tend to get bogged down into over-engineering the initial stuff, so this time I want to go the way of building something quick and possibly dirty, and cleaning up stuff afterwards :P

But thank you for the references, I will read through them with more concentration during the weekend.

Share this post


Link to post
Share on other sites
I think I will be happy for the beginning with SCANutil providing me access to SCANdata.Anomalies

Knowing myself, I tend to get bogged down into over-engineering the initial stuff, so this time I want to go the way of building something quick and possibly dirty, and cleaning up stuff afterwards :P

But thank you for the references, I will read through them with more concentration during the weekend.

Any suggestions or requests for this type of methods should be submitted as issues to the SCANsat repo, or as a pull request, preferably to my active branch found here.

I'll add pretty much anything within reason. Just keep in mind that the simplest methods (especially if you are using reflection) don't use any non-generic types. So something that returns results using only common types (string, bool, lists, etc...) will be much easier to use.

For more examples of reflection stuff using these simple static methods you can check out how SCANsat handles Regolith interaction. It is very easy to set up when you have methods designed specifically for it.

Edited by DMagic

Share this post


Link to post
Share on other sites
Any suggestions or requests for this type of methods should be submitted as issues to the SCANsat repo, or as a pull request, preferably to my active branch found here.

Thank you, I was halfway there to have the PR, but then decided to rather go all the way and implement my own addon. If nothing else, I will have learned some more C# :)

The method exposed in SCANUtil is already fine for now.

Share this post


Link to post
Share on other sites

Also make sure to follow along with my active branch if you start using anything other than those exposed SCANUtil methods (those should always remain unchanged for the foreseeable future). A lot of other types and methods are getting move around and their accessibility levels will change in the next update. So there is a good chance that anything designed to work with the current dev version will break in the next version.

Share this post


Link to post
Share on other sites

New version is out, fixes to the KerbalSpawner (it really wasn't working right before), and a fix provided by tattagreis. Download it now!

Contract Configurator 0.5.5

- Fixed issue in ReachState where empty situation caused issues (thanks tattagreis).

- Fixed problems with KerbalSpawner.

- Added new attribute to KerbalSpawner to have the Kerbal added to the roster (thanks scerion).

Share this post


Link to post
Share on other sites

1. is there any fuction to enable "ghost orbit" which shows what orbit is in contract?

2. is there fuction to check if specific mission was done before? i want to make chain constarcts.

Share this post


Link to post
Share on other sites

Is there any way to turn off stock contracts and keep those from yours and others mods? I hate those stock random missions

Edited by zcaalock

Share this post


Link to post
Share on other sites
Is there any way to turn off stock contracts and keep those from yours and others mods? I hate those stock random missions

Sure is, see the Miscellaneous page on the wiki.

Share this post


Link to post
Share on other sites
New version is out, fixes to the KerbalSpawner (it really wasn't working right before), and a fix provided by tattagreis. Download it now!

Contract Configurator 0.5.5

- Fixed issue in ReachState where empty situation caused issues (thanks tattagreis).

- Fixed problems with KerbalSpawner.

- Added new attribute to KerbalSpawner to have the Kerbal added to the roster (thanks scerion).

Nightingale you're the best :D

Share this post


Link to post
Share on other sites

Alright, This does seem to potentially be one of the issues related to it, I don't know what the other thing causing this conflict is, but well, Where do I find the Output log?

*EDIT*

Err, because I found another issue, with this mod installed, it's clashing somewhere and I can't collect -any- science period, transmitted, landed, or even mission science.

Share this post


Link to post
Share on other sites

in Kerbals main directory is a KSP.log file. While ingame you have two options, alt + f2 opens the logger or alt + f12 and switch to debug.

Share this post


Link to post
Share on other sites

Thanks for the update!

Testing on 0.5.5 (not sure if it was existing in 0.5.4)

In my ReachState parameters if I set a minAltitude but no maxAltitude, there seems to be a default maxAltitude set (at Double.MaxValue? the wiki entry for ReachState isn't specific).

This results in Mission Control Line:

Altitude: Between 70,000 m and 340,282,300,000,000,000,000,000,000,000 ... 000 : Incomplete

I guess I was expecting 'Altitude: Greater than 70,000 m' or something.

Am I doing something wrong? Should I raise an enhancement issue?:

    PARAMETER    {
// TODO: Wait for a way to detect docking is created
// See https://github.com/jrossignol/ContractConfigurator/issues/86
name = ReachStateDocked
type = ReachState


// Minimum and maximum altitudes.
minAltitude = 70000


// The situation. Valid values from Vessel.Situations:
// ESCAPING
// FLYING
// LANDED
// ORBITING
// PRELAUNCH
// SPLASHED
// SUB_ORBITAL
situation = ORBITING


// Text to use for the parameter
// Default Vessel State: <state details>
title = Vessel is orbiting Kerbin
}

Thanks!

Share this post


Link to post
Share on other sites

I just made my own branch and pull request on a project for the first time! Just a minor display correction to fix this

EfJugQH.png?1

Edited by DBT85

Share this post


Link to post
Share on other sites
I just made my own branch and pull request on a project for the first time!

Welcome to the Git world :)

Share this post


Link to post
Share on other sites
Welcome to the Git world :)

Took me a good chunk of Monday to get into it and work out what I was doing! I've done little bits of code before with my website and a timecode calculator for work so I'm mostly out of my depth. My brother is head of webdev and IT for Iglu.com though so you'd think I'd pick stuff up :P

EDIT:

Is it possible to put a requirement into a parameter? So for example, This optional parameter within a contract will not be available to the player unless they've unlocked the required part. I've tried this code in the contract and everything is displaying exactly the same as it would without the requirement. Not sure if I'm just doing it wrong or if its not looking for requirements within parameters.

PARAMETER    {

name = Option1
type = All


title = (Optional 1) Take a SCAN Multispectral Sensor and gather Biome data from Eve
optional = True

// Parameter rewards
rewardScience = 10.0
rewardReputation = 10.0
rewardFunds = 10000.0

PARAMETER
{
name = SCANsatCoverage3
type = SCANsatCoverage
targetBody = Eve
coverage = 25.0
scanType = Biome
}

REQUIREMENT
{
name = PartUnlocked1
type = PartUnlocked

Part name that needs to be unlocked.
part = SCANsat_Scanner24
}
}

Edited by DBT85

Share this post


Link to post
Share on other sites
I just made my own branch and pull request on a project for the first time! Just a minor display correction to fix this

http://i.imgur.com/EfJugQH.png?1

And you just got your first pull request accepted!

Took me a good chunk of Monday to get into it and work out what I was doing! I've done little bits of code before with my website and a timecode calculator for work so I'm mostly out of my depth. My brother is head of webdev and IT for Iglu.com though so you'd think I'd pick stuff up :P

I'm not sure that's how it works.... "Don't worry, everything's going to be fine, my sister's head of neurosurgery, this won't hurt a bit... just hold very still."

EDIT:

Is it possible to put a requirement into a parameter? So for example, This optional parameter within a contract will not be available to the player unless they've unlocked the required part. I've tried this code in the contract and everything is displaying exactly the same as it would without the requirement. Not sure if I'm just doing it wrong or if its not looking for requirements within parameters.

PARAMETER    {

name = Option1
type = All


title = (Optional 1) Take a SCAN Multispectral Sensor and gather Biome data from Eve
optional = True

// Parameter rewards
rewardScience = 10.0
rewardReputation = 10.0
rewardFunds = 10000.0

PARAMETER
{
name = SCANsatCoverage3
type = SCANsatCoverage
targetBody = Eve
coverage = 25.0
scanType = Biome
}

REQUIREMENT
{
name = PartUnlocked1
type = PartUnlocked

Part name that needs to be unlocked.
part = SCANsat_Scanner24
}
}

That isn't supported, but it's an interesting idea, and it opens up lots of possibilities with minimal coding effort. I'll put it on the roadmap for 0.6.0.

Oh, and you should've gotten a warning in the logs trying to do that - something along the lines of "Unexpected child node 'REQUIREMENT'". If you didn't then that's a problem (albeit a small one).

Share this post


Link to post
Share on other sites
I'm not sure that's how it works.... "Don't worry, everything's going to be fine, my sister's head of neurosurgery, this won't hurt a bit... just hold very still."

Shame :( lol

That isn't supported, but it's an interesting idea, and it opens up lots of possibilities with minimal coding effort. I'll put it on the roadmap for 0.6.0.

Oh, and you should've gotten a warning in the logs trying to do that - something along the lines of "Unexpected child node 'REQUIREMENT'". If you didn't then that's a problem (albeit a small one).

something something not checking the logs something something.

Thanks :)

Share this post


Link to post
Share on other sites

i posted in wrong thread before..

how to make prelaunch to hold result? After launch parameter is going back to x

PARAMETER
{
name = ReachState
type = ReachState

situation = PRELAUNCH
}

2nvs5r6.jpg

and after launch:

290vrqs.jpg

from where "destination" is comming from?

here is whole code:



CONTRACT_TYPE:NEEDS[SCANsat]
{
name = ScanMun

// Contract text
title = Karbonite Scan Mun
description = We need answers! And snacks!!! You are required to create an Altimetry scan of Mun's surface.\n This will greatly enhance our knowledge about our moons, snacks and everything.
synopsis = Reach a fitting orbit and scan Mun's surface.
completedMessage = HQ will be statisfied!

// Controls for whether a contract can be declined or cancelled, default is true for both
cancellable = true
declinable = true

// Target Celestial body - controls where the contract must be completed, has some automated
// effects on numeric parameters (increasing science, etc.)
targetBody = Mun

// Contract rewards
rewardScience = 25.0
rewardReputation = 40.0
rewardFunds = 20000.0

// Can only be done once
maxCompletions = 1
maxSimultaneous = 1

prestige = Significant



PARAMETER
{
name = VesselParameterGroup1
type = VesselParameterGroup

PARAMETER
{
name = HasCrew1
type = HasCrew
maxCrew = 0
minCrew = 0
}

PARAMETER
{
name = PartValidation1
type = PartValidation

part = KA_DetectionArray_01
minCount = 1
}

PARAMETER
{
name = ReachState
type = ReachState

situation = PRELAUNCH
}

}

PARAMETER
{

name = ReachSpecificOrbit
type = ReachSpecificOrbit

// The index (0-based) in the OrbitGenerator behaviour of the orbit we
// wish to reference.
// Default = 0
index = 0

// The deviation window for how close we must match the given orbit.
// wish to reference. Higher values give more room for error. Note: More
// testing is required to better document the realistic range of values.
// Default = 3.0
deviationWindow = 5.0
}

BEHAVIOUR
{
name = OrbitGenerator
type = OrbitGenerator

// Use this to generate an orbit with specific parameters
FIXED_ORBIT
{
// Body for the orbit - defaulted from the contract if not supplied
targetBody = Mun

// Actual orbit details. Note that REF represents the reference
// body - but will be overriden by the targetBody.

ORBIT
{
SMA = 500001.234556523
ECC = 1.07570816555399E-05
INC = 82
LPE = 270.690311604893
LAN = 1.93635924563296
MNA = 1.55872660382504
EPH = 31.3999999999994
REF = 1
}
}
}

PARAMETER
{
name = SCANsatCoverage1
type = SCANsatCoverage

// More than 90% coverage
coverage = 90.0
// See https://github.com/jrossignol/ContractConfigurator/wiki/Parameters#scansatcoverage to get the full list of SanTypes
scanType = Karbonite
}

PARAMETER
{
name = Duration
type = Duration

// The duration the timer is set to. Can specify values in years (y),
// days (d), hours (h), minutes (m), seconds (s) or any combination of
// those.
duration = 30m 10s

// The preWaitText overrides the text that is displayed when waiting
// for the other parameters to complete.
// Default = Waiting time required
preWaitText = Hold the satellite in position for 30m 10s to scan the surface.

// The waitingText overrides the text that is displayed when waiting
// for the timer to expire.
// Default = Time to completion
waitingText = Scanning surface

// The completionText is displayed when the timer completes.
// Default = Wait time over
completionText = Scane done
}


REQUIREMENT
{
name = TechResearched
type = TechResearched

// The technology that needs to have been researched. Take special note that
// this does not get validated - if you make a typo, the requirement will
// always return false.
tech = fuelSystems
}

}

Share this post


Link to post
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.