Jump to content

Stock Fuel Switch


Porkjet

Recommended Posts

I tried the Interstellar Fuel Switch config but for some reason it didn't seem to be working. None of the stock tanks were switchable. I have no idea what the issue could be as the config looks perfectly fine and Interstellar Fuel Switch was working fine with other mods that use it directly.

So instead I made some similar improvements for the FireSpitter Fuel Switch config if anybody else is interested.

Spoiler
//Code by Badsector, Nertea, and veryinky
 
@PART[*]:HAS[@RESOURCE[LiquidFuel],@RESOURCE[Oxidizer],!MODULE[FSfuelSwitch],!MODULE[InterstellarFuelSwitch]]:FOR[Firespitter] {  
 
    // temporary variables - if you add one here, add it below in cleanup, too
    %tempVar = 0
    %totalCap = 0
    %dryCost = 0
    %LF = 0
    %LFCost = 0
    %OX = 0
    %OXCost = 0
    %mixLFCost = 0
 
    // Total tank capacity
    @LF = #$RESOURCE[LiquidFuel]/maxAmount$
    @OX = #$RESOURCE[Oxidizer]/maxAmount$
   
    @totalCap = #$RESOURCE[LiquidFuel]/maxAmount$
    @totalCap += #$RESOURCE[Oxidizer]/maxAmount$
   
    @dryCost = #$cost$
   
    // compute cost of stock tank fuel
    @tempVar = #$RESOURCE[LiquidFuel]/maxAmount$
    @tempVar *= 0.8
    @mixLFCost += #$tempVar$
   
    @tempVar = #$RESOURCE[Oxidizer]/maxAmount$
    @tempVar *= 0.18
    @mixLFCost += #$tempVar$
   
    @dryCost -= #$mixLFCost$
    @cost -= #$mixLFCost$
   
    // Cost LF only
    @tempVar = #$totalCap$
    @tempVar *= 0.8
    @LFCost += #$tempVar$
   
    // Cost OX only
    @tempVar = #$totalCap$
    @tempVar *= 0.18
    @OXCost += #$tempVar$
   
    @tempVar = 0
 
    MODULE {
        name = FSfuelSwitch
 
        resourceNames = LiquidFuel,Oxidizer;LiquidFuel
        resourceAmounts = #$../LF$,$../OX$;$../totalCap$
        tankCost = #$../mixLFCost$;$../LFCost$
 
        displayCurrentTankCost = true
        hasGUI = true
        showInfo = true
        availableInFlight = false
        availableInEditor = true
 
        basePartMass = #$../mass$
        tankMass = 0;0;0;0;0
    }
}
 
@PART[*]:HAS[@RESOURCE[LiquidFuel],@RESOURCE[Oxidizer],@MODULE[FSfuelSwitch],!MODULE[InterstellarFuelSwitch]]:AFTER[Firespitter] {  
 
    // temporary variables cleanup to supress PartLoader warnings
    !tempVar = DELETE
    !totalCap = DELETE
    !dryCost = DELETE
    !LF = DELETE
    !LFCost = DELETE
    !OX = DELETE
    !OXCost = DELETE
    !mixLFCost = DELETE
 
    !RESOURCE[LiquidFuel] {}
    !RESOURCE[Oxidizer] {}
}
 

@PART[*]:HAS[@RESOURCE[LiquidFuel],!@RESOURCE[Oxidizer],!MODULE[FSfuelSwitch],!MODULE[InterstellarFuelSwitch]]:FOR[Firespitter] {  
 
    // temporary variables - if you add one here, add it below in cleanup, too
    %tempVar = 0
    %totalCap = 0
    %dryCost = 0
    %LF = 0
    %LFCost = 0
    %OX = 0
    %OXCost = 0
    %mixLFCost = 0
 
    // Total tank capacity
    @LF = #$RESOURCE[LiquidFuel]/maxAmount$
    @OX = #$LF$
   
    @totalCap = #$RESOURCE[LiquidFuel]/maxAmount$
   
    @OX *= 0.55
    @LF *= 0.45
   
    @dryCost = #$cost$
   
    // compute cost of stock tank fuel
    @tempVar = #$LF$
    @tempVar *= 0.8
    @mixLFCost += #$tempVar$
   
    @tempVar = #$OX$
    @tempVar *= 0.18
    @mixLFCost += #$tempVar$
   
    @dryCost -= #$mixLFCost$
    @cost -= #$mixLFCost$
   
    // Cost LF only
    @tempVar = #$totalCap$
    @tempVar *= 0.8
    @LFCost += #$tempVar$
   
    // Cost OX only
    @tempVar = #$totalCap$
    @tempVar *= 0.18
    @OXCost += #$tempVar$
   
    @tempVar = 0
 
    MODULE {
        name = FSfuelSwitch
 
        resourceNames = LiquidFuel,Oxidizer;LiquidFuel
        resourceAmounts = #$../LF$,$../OX$;$../totalCap$
        tankCost = #$../mixLFCost$;$../LFCost$
 
        displayCurrentTankCost = true
        hasGUI = true
        showInfo = true
        availableInFlight = false
        availableInEditor = true
 
        basePartMass = #$../mass$
        tankMass = 0;0;0;0;0
    }
}
 
@PART[*]:HAS[@RESOURCE[LiquidFuel],!RESOURCE[Oxidizer],@MODULE[FSfuelSwitch],!MODULE[InterstellarFuelSwitch]]:AFTER[Firespitter] {  
 
    // temporary variables cleanup to supress PartLoader warnings
    !tempVar = DELETE
    !totalCap = DELETE
    !dryCost = DELETE
    !LF = DELETE
    !LFCost = DELETE
    !OX = DELETE
    !OXCost = DELETE
    !mixLFCost = DELETE
 
 !RESOURCE[LiquidFuel] {}
}

 

Edited by Jonney5
Link to comment
Share on other sites

3 hours ago, Jonney5 said:

I tried the Interstellar Fuel Switch config but for some reason it didn't seem to be working. None of the stock tanks were switchable. I have no idea what the issue could be as the config looks perfectly fine and Interstellar Fuel Switch was working fine with other mods that use it directly.

So instead I made some similar improvements for the FireSpitter Fuel Switch config if anybody else is interested.

@Jonney5 Latest update to KSP 1.1 was a bit codebreaking for the "switching mods". FreeThinker has already fixed the InterStellarFuelSwitch, you need to get the latest version.

Edited by Enceos
Link to comment
Share on other sites

  • 2 weeks later...
On 6-5-2016 at 10:35 PM, fireblade274 said:

I'd like to see it come stock

 

I thought that was implied lol

Note , Interstellar Fuel Switch also contains a script which will add Fuel switching to stock Liquid Fuel + Oxidiser tanks. Beside fuel switching it also shown more information and improved rGUI

Edited by FreeThinker
Link to comment
Share on other sites

20 minutes ago, OldLost said:

Was that a recent addition to IFS? Because I seem to remember a while back when I installed IFS I did not have that option on stock tanks.

Yes it is, starting from IFS 2.0, it now also does switching on stock fuel tanks, which was many times requested. The of  resource you can switch to is also limited to unlocked tech nodes. This means resources like Monopropellant and Xenon only becomes avialbe after the stock tanks have been unlocked

Edited by FreeThinker
Link to comment
Share on other sites

  • 1 month later...

Reposting this from the previous page for visibility

On 3/29/2016 at 5:18 PM, PocketBrotector said:

If you want to use StockFuelSwitch, it's just this config plus the dependencies (InterstellarFuelSwitch and ModuleManager):

  Hide contents

 



// Code by Badsector, Nertea and veryinky
// LF tanks added by Bigglesworth, 24th July 2015
// Keep resource nodes, fix LF changed by SpaceNomad, 23rd August 2015
// moved to InterstellarFS, refactored, cleaned log warnings and made to work with tanks that aren't full by default by TRauMa, 29th August 2015 

// we could add :NEEDS[InterstellarFuelSwitch], but as we only touch the InterstellarFuelSwitch node, it's not really necessary  

// -----------------------
// LFOX tanks
// -----------------------
@PART[*]:HAS[@RESOURCE[LiquidFuel],@RESOURCE[Oxidizer],!MODULE[FSfuelSwitch],!MODULE[InterstellarFuelSwitch]]:FOR[InterstellarFuelSwitch] {   

    // temporary variables - if you add one here, add it below in cleanup, too
    %tempVar = 0
    %resCost = 0
    %totalCap = 0
    %dryCost = 0
    %LFCost = 0
    %OXCost = 0

    // Total tank capacity
    @totalCap = #$RESOURCE[LiquidFuel]/maxAmount$
    @totalCap += #$RESOURCE[Oxidizer]/maxAmount$

    // compute cost of fuel fitting in part
    @tempVar = #$RESOURCE[LiquidFuel]/maxAmount$
    @tempVar *= 0.8
    @resCost = #$tempVar$

    @tempVar = #$RESOURCE[Oxidizer]/maxAmount$
    @tempVar *= 0.18
    @resCost += #$tempVar$

    // and get dry cost as total cost - resource cost
    @dryCost = #$cost$
    @dryCost -= #$resCost$
    // we don't really use dryCost yet, but as LF tanks are more expensive in stock than their LFOX counterparts, this may change

    // Now compute tank costs adaption as new res costs - old res costs
    // - LF
    @tempVar = #$totalCap$
    @tempVar *= 0.8
    @LFCost += #$tempVar$
    @LFCost -= #$resCost$

    // - OX
    @tempVar = #$totalCap$
    @tempVar *= 0.18
    @OXCost += #$tempVar$
    @OXCost -= #$resCost$

    MODULE {
        name = InterstellarFuelSwitch

        # the first option should leave the tank like it is in stock
        resourceGui = Rocket Fuel;Liquid Fuel;Oxidizer
        resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
        resourceAmounts = #$../RESOURCE[LiquidFuel]/maxAmount$,$../RESOURCE[Oxidizer]/maxAmount$;$../totalCap$;$../totalCap$
        initialResourceAmounts = #$../RESOURCE[LiquidFuel]/amount$,$../RESOURCE[Oxidizer]/amount$;$../totalCap$;$../totalCap$
        tankCost = #0;$../LFCost$;$../OXCost$

        displayCurrentTankCost = true

        hasGUI = true
        showInfo = true

        availableInFlight = false
        availableInEditor = true

        basePartMass = #$../mass$
        tankMass = 0;0;0;0;0
    }

}


@PART[*]:HAS[@RESOURCE[LiquidFuel],@RESOURCE[Oxidizer],!MODULE[FSfuelSwitch],@MODULE[InterstellarFuelSwitch]]:AFTER[InterstellarFuelSwitch] {   

    // temporary variables cleanup to supress PartLoader warnings
    !tempVar = DELETE
    !resCost = DELETE
    !totalCap = DELETE
    !dryCost = DELETE
    !LFCost = DELETE
    !OXCost = DELETE

}


// -----------------------
// LF tanks
// -----------------------
@PART[*]:HAS[@RESOURCE[LiquidFuel],!RESOURCE[Oxidizer],!MODULE[FSfuelSwitch],!MODULE[InterstellarFuelSwitch]]:FOR[InterstellarFuelSwitch] {   

    // temporary variables - if you add one here, add it below in cleanup, too
    %tempVar = 0
    %resCost = 0
    %dryCost = 0
    %mixCost = 0
    %OXCost = 0
    %LFcap = 0
    %OXcap = 0

    // compute cost of fuel in part if at capacity
    @resCost = #$RESOURCE[LiquidFuel]/maxAmount$
    @resCost *= 0.8

    // and get dry cost as total cost - resource cost
    @dryCost = #$cost$
    @dryCost -= #$resCost$

    // Now compute tank costs as dry costs + res costs at capacity
    // - LFOX (also calculate caps: 45% of full cap for LF)
    @LFcap = #$RESOURCE[LiquidFuel]/maxAmount$
    @LFcap *= 0.45
    @tempVar = #$LFcap$
    @tempVar *= 0.8
    @mixCost += #$tempVar$
    @OXcap = #$RESOURCE[LiquidFuel]/maxAmount$
    @OXcap *= 0.55
    @tempVar = #$OXcap$
    @tempVar *= 0.18
    @mixCost += #$tempVar$
    @mixCost -= #$resCost$

    // - OX
    @tempVar = #$RESOURCE[LiquidFuel]/maxAmount$
    @tempVar *= 0.18
    @OXCost += #$tempVar$
    @OXCost -= #$resCost$

    MODULE {
        name = InterstellarFuelSwitch

        # the first option should leave the tank like it is in stock
        resourceGui = Liquid Fuel;Oxidizer;Rocket Fuel
        resourceNames = LiquidFuel;Oxidizer;LiquidFuel,Oxidizer
        resourceAmounts = #$../RESOURCE[LiquidFuel]/maxAmount$;$../RESOURCE[LiquidFuel]/maxAmount$;$../LFcap$,$../OXcap$
        initialResourceAmounts = #$../RESOURCE[LiquidFuel]/amount$;$../RESOURCE[LiquidFuel]/maxAmount$;$../LFcap$,$../OXcap$
        tankCost = #0;$../OXCost$;$../mixCost$

        displayCurrentTankCost = true

        hasGUI = true
        showInfo = true

        availableInFlight = false
        availableInEditor = true

        basePartMass = #$../mass$
        tankMass = 0;0;0;0;0
    }

}

@PART[*]:HAS[@RESOURCE[LiquidFuel],!RESOURCE[Oxidizer],!MODULE[FSfuelSwitch],@MODULE[InterstellarFuelSwitch]]:AFTER[InterstellarFuelSwitch] {   

    // temporary variables cleanup to supress PartLoader warnings
    !tempVar = DELETE
    !resCost = DELETE
    !dryCost = DELETE
    !mixCost = DELETE
    !OXCost = DELETE
    !LFcap = DELETE
    !OXcap = DELETE

}

 

Copy and paste that into a text editor like Notepad, save it as something like StockFuelSwitch.cfg, and drop it and the dependencies into your GameData folder.

 

 

Edited by mythbusters844
Link to comment
Share on other sites

  • 5 months later...
On 6/27/2016 at 11:23 PM, mythbusters844 said:

Reposting this from the previous page for visibility

 

 

How current is this? Has this basically been superseded, or is it still possible to find some fuel-switching mod that doesn't involve installing new tanks?

Link to comment
Share on other sites

On 11/28/2016 at 0:56 AM, ExplorerKlatt said:

It should still work as long as the dependencies are updated. 

Do I need to uninstall IFS if I have it installed? I installed a couple of mods last night (StarLionIndustries and AtomicAge, and Mk2 Extended iirc), and suddenly I could not edit the fuel type of any tank in the VAB. So I tried uninstalling a few.

------

Here is a download link for anyone like me who can't reach the official one at Kerbalstuff:  

 https://spacedock.info/mod/366/Stock Fuel Switch

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