Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What would I need to add this to CactEye #20

Open
linuxgurugamer opened this issue Nov 12, 2020 · 16 comments
Open

What would I need to add this to CactEye #20

linuxgurugamer opened this issue Nov 12, 2020 · 16 comments

Comments

@linuxgurugamer
Copy link

I assume that if I copy these lines:

https://github.com/ChrisAdderley/SpaceDust/blob/659416c9e1a8c381ff6d1bdc9e03a2be4eaba771/GameData/SpaceDust/Parts/Scanning/spacedust-telescope-1.cfg#L41-L298

and add them to the two CactEye telescopes (using a MM patch)

and then change the following to match the telescope:

    // Power cost per second when scanning
    PowerCost = 12
    // Size of the lens/mirror, for calcuations
    ObjectiveSize = 1.8
    // FOV (radians)
    FieldOfView = 0.000969627362992369

that is al that would be needed?

@linuxgurugamer
Copy link
Author

I added the following patch to the CactEye mod, and am getting endless Nullrefs:
NullReferenceException: Object reference not set to an instance of an object at SpaceDust.ModuleSpaceDustTelescope.FixedUpdate () [0x00281] in <ba654944d2a34d95a0875ec0fa773920>:0 UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object) UnityEngine.DebugLogHandler:LogException(Exception, Object) ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object) UnityEngine.Logger:LogException(Exception, Object) UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

`@PART[tele_body,tele_body2]:NEEDS[SpaceDust]
{

MODULE 
{ 
    name = ModuleSpaceDustTelescope 
    // Power cost per second when scanning 
    PowerCost = 12 
    // Animation 
    ScanAnimationName = OpenDoor 
    // Size of the lens/mirror, for calcuations 
    ObjectiveSize = 1.8 
    // FOV (radians) 
    FieldOfView = 0.000969627362992369 

    SLOT 
    { 
        name = slot1 
        Instrument = None 
    } 
    SLOT 
    { 
        name = slot2 
        Instrument = None 
    } 
}  

MODULE 
{ 
    name = ModuleB9PartSwitch 
    moduleID = instrumentSlot1 
    switcherDescription = #LOC_SpaceDust_switcher_instrument_slot1_title 

    SUBTYPE 
    { 
        name = None 
        title = #LOC_SpaceDust_switcher_instrument_none 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_none_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_none_detail 
        primaryColor = #111111 
        secondaryColor = #111111 
        addedMass = 0 
        addedCost = 0 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot1 
                    Instrument = None 
                } 
            } 
        } 
    } 
    // 
    SUBTYPE 
    { 
        name = XeInstrument 
        title = #LOC_SpaceDust_switcher_instrument_xe 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_xe_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_xe_detail 
        primaryColor = #60a7be 
        secondaryColor = #60a7be 
        addedMass = 0.2 
        addedCost = 50000 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot1 
                    Instrument = XenonSpectrometer 
                } 
            } 
        } 
    } 
    SUBTYPE 
    { 
        name = OxInstrument 
        title = #LOC_SpaceDust_switcher_instrument_ox 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_ox_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_ox_detail 
        primaryColor = #3399cc 
        secondaryColor = #3399cc 
        addedMass = 0.2 
        addedCost = 50000 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot1 
                    Instrument = OxidizerSpectrometer 
                } 
            } 
        } 
    } 
    SUBTYPE 
    { 
        name = LFInstrument 
        title = #LOC_SpaceDust_switcher_instrument_lf 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_lf_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_lf_detail 
        primaryColor = #3399cc 
        secondaryColor = #3399cc 
        addedMass = 0.2 
        addedCost = 50000 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot1 
                    Instrument = LiquidFuelSpectrometer 
                } 
            } 
        } 
    } 
} 
MODULE 
{ 
    name = ModuleB9PartSwitch 
    moduleID = instrumentSlot2 
    switcherDescription = #LOC_SpaceDust_switcher_instrument_slot2_title 

    SUBTYPE 
    { 
        name = None 
        title = #LOC_SpaceDust_switcher_instrument_none 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_none_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_none_detail 
        primaryColor = #111111 
        secondaryColor = #111111 
        addedMass = 0 
        addedCost = 0 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot2 
                    Instrument = None 
                } 
            } 
        } 
    } 
    // 
    SUBTYPE 
    { 
        name = XeInstrument 
        title = #LOC_SpaceDust_switcher_instrument_xe 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_xe_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_xe_detail 
        primaryColor = #60a7be 
        secondaryColor = #60a7be 
        addedMass = 0.2 
        addedCost = 50000 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot2 
                    Instrument = XenonSpectrometer 
                } 
            } 
        } 
    } 
    SUBTYPE 
    { 
        name = OxInstrument 
        title = #LOC_SpaceDust_switcher_instrument_ox 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_ox_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_ox_detail 
        primaryColor = #3399cc 
        secondaryColor = #3399cc 
        addedMass = 0.2 
        addedCost = 50000 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot2 
                    Instrument = OxidizerSpectrometer 
                } 
            } 
        } 
    } 
    SUBTYPE 
    { 
        name = LFInstrument 
        title = #LOC_SpaceDust_switcher_instrument_lf 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_lf_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_lf_detail 
        primaryColor = #3399cc 
        secondaryColor = #3399cc 
        addedMass = 0.2 
        addedCost = 50000 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot2 
                    Instrument = LiquidFuelSpectrometer 
                } 
            } 
        } 
    }       
}

}

@part[tele_body]:NEEDS[SpaceDust]
{

@MODULE[ModuleSpaceDustTelescope]
{ 
    @PowerCost = 16
    @ScanAnimationName = tele_openaperture 
    @ObjectiveSize = 2.5
    @FieldOfView = 0.000969627362992369 
} 

}

@part[tele_body2]:NEEDS[SpaceDust]
{

@MODULE[ModuleSpaceDustTelescope]
{ 
    @PowerCost = 10
    @ScanAnimationName = body2_open 
    @ObjectiveSize = 1.6
    @FieldOfView = 0.000969627362992369 
} 

}

`

@ChrisAdderley
Copy link
Collaborator

Uh that's the right approach. Maybe you can post the final cached patched version of the config and the full log? There may be an initialization error.

@linuxgurugamer
Copy link
Author

Of course, now that I went to get you the info, it works perfectly :-(

I'd like to leave this open for a bit, so that if it happens again I can just add to this. I'll close it in a few days if it doesn't come back. May have been a "funny" in the test install I was using

@linuxgurugamer
Copy link
Author

linuxgurugamer commented Nov 19, 2020

Ok, in my latest test, got the null refs I mentioned before.
I created a new game (included in the zip). career mode.
Cheated funds, technology, facilities to max
Went into the VAB, opened a vessel consisting of the Cacti telescope fully assembled (in the save as an auto-save)
Selected Xenon for slot 1
Launched.
Got endless nullrefs of the following:
NullReferenceException: Object reference not set to an instance of an object at SpaceDust.ModuleSpaceDustTelescope.FixedUpdate () [0x00207] in <ba654944d2a34d95a0875ec0fa773920>:0 UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object) UnityEngine.DebugLogHandler:LogException(Exception, Object) ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object) UnityEngine.Logger:LogException(Exception, Object) UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object

Part with the dust telescope is: CactEye/Parts/tele_body/tele_body.cfg
starting at line 6515 in the ModuleManager.configcache

SpaceDustLogMMCache.zip

@linuxgurugamer
Copy link
Author

I traced the problem to the fact that the scanState seems to be uninitialized at the following line: https://github.com/ChrisAdderley/SpaceDust/blob/659416c9e1a8c381ff6d1bdc9e03a2be4eaba771/Source/SpaceDust/Modules/ModuleSpaceDustTelescope.cs#L309

@linuxgurugamer
Copy link
Author

linuxgurugamer commented Nov 19, 2020

Ok, so I found the following:

First error occured right after switching to the flight scene, here:
Module ModuleSpaceDustTelescope threw during OnLoad: System.NullReferenceException: Object reference not set to an instance of an object at SpaceDust.SpaceDustInstruments.GetInstrument (System.String name) [0x00000] in <6178720041ed44b7ba6da33fbb519eae>:0 at SpaceDust.InstrumentSlot..ctor (ConfigNode node) [0x0004d] in <6178720041ed44b7ba6da33fbb519eae>:0 at SpaceDust.ModuleSpaceDustTelescope.OnLoad (ConfigNode node) [0x00034] in <6178720041ed44b7ba6da33fbb519eae>:0 at PartModule.Load (ConfigNode node) [0x001ab] in <c1858a3f77504bd1aaa946fdccf84670>:0

The problem is in SpaceDustInstruments, the GetInstrument(string name), I found that Instruments is null.

I have a dev environment for it, so if you want to have me try something, just let me know. All I've done so far is add Debug.Log statements to trace where the exception is happening.

Hope this helps

@linuxgurugamer
Copy link
Author

For the record adding the following code right after GetInstrument(string name), in SpaceDustInstruments.cs, after line 34, fixed it. Not a recommended fix, it's just a patch to see if it is just an initialization problem:
if (Instruments == null) Load();

@ChrisAdderley
Copy link
Collaborator

The thing that's confusing me is that last I checked everything was fine with my parts, so I need to take some time to investigate this in your context.

@linuxgurugamer
Copy link
Author

ok. I just pushed everything, and here is a beta release if you need it to test

CactEyeBeta.zip

@linuxgurugamer
Copy link
Author

I wonder if it could be the order of the modules in the config?

@ChrisAdderley
Copy link
Collaborator

Not sure. I'm working on other projects right now but I will investigate this when I get a chance (maybe tomorrow night, maybe tonight)

@ChrisAdderley
Copy link
Collaborator

I made a new release that added the initialization change you made - it seems like a good move.

@linuxgurugamer
Copy link
Author

Thank you.

@linuxgurugamer
Copy link
Author

Hi,

Just tested. Seems that the release doesn't include that fix, I still got the error. So I looked at the dll using ILSpy, the fix isn't in there.

LGG

@ChrisAdderley
Copy link
Collaborator

Huh, I'll look in more detail when I have a moment.

@ChrisAdderley
Copy link
Collaborator

I installed that zip you added above to try to test and unfortunately couldn't - on placing the cacteye large telescope in the VAB log got flooded with errors related to CactEyeGUI. See log:
KSP.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants