Jump to content

PartModule, GetInfo() how to access ConfigNodes


Recommended Posts

For my mod I would like to access information in the CFG file, that is not loaded by KSP.

Specifically I can have two (or more) atmosphereCurve nodes, which I found no way to get KSP to load automatically into my class like [KSPField] does. What I do with the nodes is to switch the curve when enginemode is switched.

Spoiler

@PART[engineLargeSkipper]:FOR[GTI]
{
    @description = The smaller sibling of the Mainsail, the Skipper's power rivals that of... large cities. Combining high thrust with reasonable efficiency, this engine excels when used as a mid-stage booster. This upgraded version also feature a liftoff version, which uses intakeair instead of oxidizer. This is much more efficient, but also only works inside the atmosphere.

    MODULE
    {
        name = GTI_MultiModeEngine
        
        messagePosition = UPPER_RIGHT
        availableInFlight = false
        availableInEditor = true
        
        GUIengineModeNames = LFO;High Velocity LFO
        //EngineTypes =
        
        propellantNames = LiquidFuel,Oxidizer;LiquidFuel,Oxidizer
        propellantRatios = 0.9,1.1;0.9,1.1
        propIgnoreForISP = False,False;False,False
        propDrawGauge = True,True;True,True
        
        //atmChangeFlows =
        useVelCurves = False;False
        useAtmCurves = False;False

        maxThrust = 650;350
        heatProduction = 350;900
        
        infoatmosphereCurve_Vac = 320;370
        infoatmosphereCurve_Atm = 280;80
        
        atmosphereCurve
        {
            key = 0 320
            key = 1 280
            key = 6 0.001
        }
        atmosphereCurve
        {
            key = 0 370
            key = 0.15 280
            key = 1 80
            key = 6 0.001
        }

    }
}

However, I can/do load them using "part.partConfig.GetNode(..)". This is not possible in the "GetInfo()" method of the PartModule, and does therefore limit me in which information I can give in game... I implemented a workaround, defining two fields for vac/atm values. However, this is ugly and not that flexible.

Is there a way to get access to the cfg file info in the "GetInfo()" method?

 

Reference code: https://github.com/WarezCrawler/Guybrush101/blob/master/GTI_MultiModeEngine/MultiModeEngine.cs

Link to comment
Share on other sites

16 hours ago, sarbian said:

Give them different names  and they  load fine with [KSPField]. And I must say that I don't understand the need for an other engine switcher...

I do not think new names would work, since I do not know how many there are.... The amount is free so could be 2 or 4 or 5 or 10....

The need is probably a matter of how we as individuals want to play the game. Some want mode than 2 possible engine modes. Some want tank switching. Some want more or different planet.... I like the possibilities.

Link to comment
Share on other sites

If you want more than 2 engine switching then write a module that does the same thing as the stock one but support n engines. engine. Activate on 1 and engine.Shutdown() on the others. No need for un-needed complexity and to edit the engine stats live and break half the mods out there.

Link to comment
Share on other sites

Just now, sarbian said:

If you want more than 2 engine switching then write a module that does the same thing as the stock one but support n engines. engine. Activate on 1 and engine.Shutdown() on the others. No need for un-needed complexity and to edit the engine stats live and break half the mods out there.

I have done that. And this one is for normal ModuleEngine not ModuleEngineFX. They behave a bit differently for FX and I just want I few functions added. It is working as is, but I just want a simple way to get the information into GetInfo(), that's all. The rest is working... I just don't find it fair to the player having to open the CFG file to get efficiency information.

My "GTI_MultiModeEngineFX" work as the stock multimode, just more flexible.... Actually, to be fair, it is based on the same advise from you a couple of years ago :cool: And it was good advise.

Link to comment
Share on other sites

Just now, sarbian said:

ModuleEngineFX is a derived class of ModuleEngine. They work exactly the same. I doubt I advised you to do write unwarrantedly complex code

You did not, and GTI_MultiModeEngineFX is quite simple - I cannot say the same for GTI_MultiModeEngine... But using multimode with module engine messed up effects. Does not do that with effects nodes used by the moduleengineFX. Took me forever to realize that.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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