Jump to content

FSfuelSwitch to every tank


micha030201

Recommended Posts

This small ModuleManager config adds module FSfuelSwitch to every fuel tank in game, including non-stock. I'm sure someone has made something like that, but all I could find was this (http://forum.kerbalspaceprogram.com/threads/121321) config which adds FuelSwitch module to tanks personally, and works with stock tanks only. UPD: Yep, veryinky did, I'll make update which calculates cost correctly based on his code as soon as I understand how the price should be calculated (I don't really play career).

0H9QDd5.gif

Porkjets picture

Download:

Mega - https://mega.co.nz/#!VQJAwagT!yK8bc-hoUmoPm1wQloVqsPtftwbNy1jJuvumvTH6Z-4 (may be outdated)

KerbalStuff - [Defunct link removed by a moderator]

Dependencies:

ModuleManager by Sarbian - http://forum.kerbalspaceprogram.com/threads/55219

FireSpitter by Snjo - http://forum.kerbalspaceprogram.com/threads/24551

KerbalSpaceProgram by Squad - http://kerbalspaceprogram.com

I'm not sure if I need license for this, but let it be CC-BY-SA. Included in download.

There are currently 2 versions - for people who use ThermalPaint plugin (http://forum.kerbalspaceprogram.com/threads/123279) and for ones who don't. Here they are:

If you use ThermalPaint:

 
//CC-BY-SA


//This patch adds FSfuelSwitch to all tanks. It also adds thermalpaint until somebody understand how to stop FuelSwitch from deleting it.


@PART
[*]:HAS[@RESOURCE[LiquidFuel],!RESOURCE[MonoPropellant],!RESOURCE[Oxidizer]] //bipropellant tanks
{
lforox = #$/RESOURCE[LiquidFuel]/amount$ //liquid fuel or oxidizer
lfifplusox = #$/lforox$ //liquid fuel if plus oxidizer
@lfifplusox *= 0.45
oxifpluslf = #$/lforox$ //oxidizer if plus liquid fuel
@oxifpluslf *= 0.55




RESOURCE
{
    name = LiquidFuel
    amount = 0
    maxAmount = #$/lforox$
}




!RESOURCE[LiquidFuel] {}
    MODULE
    {
        name = FSfuelSwitch
        resourceNames = LiquidFuel,ThermalPaint;LiquidFuel,Oxidizer,ThermalPaint;Oxidizer,ThermalPaint
        resourceAmounts = #$/lforox$ , 200; $/lfifplusox$ , $/oxifpluslf$ , 200; $/lforox$ , 200 //200 is default amount for ThermalPaint
        initialResourceAmounts = #$/lforox$ , 0;$/lfifplusox$ , $/oxifpluslf$ , 0; $/lforox$ , 0 //for ThermalPaint to be 0 initially
        basePartMass = #$/mass$
        //tankMass = 0;0;0
        //tankCost =0;0;0
        displayCurrentTankCost = false
        hasGUI = true
        availableInFlight = false
        availableInEditor = true
        showInfo = true
    }
}


@PART
[*]:HAS[@RESOURCE[Oxidizer],@RESOURCE[LiquidFuel],!RESOURCE[MonoPropellant]] //LF only tanks
{
lfifplusox = #$/RESOURCE[LiquidFuel]/amount$ //liquid fuel if plus oxidizer
oxifpluslf = #$/RESOURCE[Oxidizer]/amount$ //oxidizer if plus liquid fuel
lforox = #$/lfifplusox$ //liquid fuel or oxidizer
@lforox += #$/oxifpluslf$


RESOURCE
{
    name = LiquidFuel
    amount = 0
    maxAmount = #$/lforox$
}




!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
    MODULE
    {
        name = FSfuelSwitch
        resourceNames = LiquidFuel,Oxidizer,ThermalPaint;LiquidFuel,ThermalPaint;Oxidizer,ThermalPaint
        resourceAmounts = #$/lfifplusox$ , $/oxifpluslf$ , 200; $/lforox$ , 200; $/lforox$ , 200 //200 is default amount for ThermalPaint
        initialResourceAmounts = #$/lfifplusox$ , $/oxifpluslf$ , 0; $/lforox$ , 0; $/lforox$ , 0 //for ThermalPaint to be 0 initially
        basePartMass = #$/mass$
        //tankMass = 0;0;0
        //tankCost =0;0;0
        displayCurrentTankCost = false
        hasGUI = true
        availableInFlight = false
        availableInEditor = true
        showInfo = true
    }
}

If you don't:

 
//CC-BY-SA


//This patch adds FSfuelSwitch to all tanks.


@PART
[*]:HAS[@RESOURCE[LiquidFuel],!RESOURCE[MonoPropellant],!RESOURCE[Oxidizer]] //bipropellant tanks
{
lforox = #$/RESOURCE[LiquidFuel]/amount$ //liquid fuel or oxidizer
lfifplusox = #$/lforox$ //liquid fuel if plus oxidizer
@lfifplusox *= 0.45
oxifpluslf = #$/lforox$ //oxidizer if plus liquid fuel
@oxifpluslf *= 0.55




RESOURCE
{
    name = LiquidFuel
    amount = 0
    maxAmount = #$/lforox$
}




!RESOURCE[LiquidFuel] {}
    MODULE
    {
        name = FSfuelSwitch
        resourceNames = LiquidFuel;LiquidFuel,Oxidizer;Oxidizer
        resourceAmounts = #$/lforox$ ; $/lfifplusox$ , $/oxifpluslf$ ; $/lforox$
        basePartMass = #$/mass$
        //tankMass = 0;0;0
        //tankCost =0;0;0
        displayCurrentTankCost = false
        hasGUI = true
        availableInFlight = false
        availableInEditor = true
        showInfo = true
    }
}


@PART
[*]:HAS[@RESOURCE[Oxidizer],@RESOURCE[LiquidFuel],!RESOURCE[MonoPropellant]] //LF only tanks
{
lfifplusox = #$/RESOURCE[LiquidFuel]/amount$ //liquid fuel if plus oxidizer
oxifpluslf = #$/RESOURCE[Oxidizer]/amount$ //oxidizer if plus liquid fuel
lforox = #$/lfifplusox$ //liquid fuel or oxidizer
@lforox += #$/oxifpluslf$


RESOURCE
{
    name = LiquidFuel
    amount = 0
    maxAmount = #$/lforox$
}




!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
    MODULE
    {
        name = FSfuelSwitch
        resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
        resourceAmounts = #$/lfifplusox$ , $/oxifpluslf$; $/lforox$; $/lforox$
        basePartMass = #$/mass$
        //tankMass = 0;0;0
        //tankCost =0;0;0
        displayCurrentTankCost = false
        hasGUI = true
        availableInFlight = false
        availableInEditor = true
        showInfo = true
    }
}

These are the same files which are included in the download.

Edited by James Kerman
link removed
Link to comment
Share on other sites

I spent a while trying to get this to work, and with MM and FS installed, I don't get a tweakable on any stock fuel tanks. I later added tweakscale for good measure and saw the tweakable for size but still nothing for fuel type/tank setup.

Edit: line 5 needs a closing ] and it should be good to go. Credit to Daz/Dazpoet.

Edited by plague006
Link to comment
Share on other sites

This small ModuleManager config adds module FSfuelSwitch to every fuel tank in game, including non-stock. I'm sure someone has made something like that, but all I could find was this (http://forum.kerbalspaceprogram.com/threads/121321) config which adds FuelSwitch module to tanks personally, and works with stock tanks only.

I wrote a config that works for all fuel tanks, stock or mod, at the end of that thread, plus it calculates empty tank prices correctly. You're welcome to use it if you want.

I've also written a more advanced version that allows for a 20%monoprop/80%lf+oxy, 20%monoprop/80%oxy, and 10% battery+10% monoprop+80%lf+oxy

For all in one "service module" style fuel tanks.

Link to comment
Share on other sites

Back in .23 or so I had a tweakable on my procedural tanks that allowed them to be LF/O, LF, monoprop, xenon, etc. that I'd love to have back. It's annoying to have to switch tanks if I decide monoprop might work better in a design.

I'm now also using Nertea's cryoengines so I guess such a solution would have to utilize InterstellarFS rather than Firespitter. I wonder if I could use veryinky's FSFS code for most tanks and then have a different part for hydrolox using IFS. Any thoughts?

Link to comment
Share on other sites

I guess such a solution would have to utilize InterstellarFS rather than Firespitter.

I don't understand what exactly is different between InterstellarFuelSwitch and FSfuelSwitch. As far as I understand you just want to switch between more resources instead of LF/OX,LF,OX? Adding more resources to fuel tank isn't hard on it's own, the tricky part is to calculate amounts correctly. Currently my config calculates it by taking amounts of LF and OX from tanks and adding them, because their density is the same. I'll try to make it use more complicated approach, but I don't have much to offer by now.

Link to comment
Share on other sites

  • 1 month later...

BTW, I opened an issue on CKAN concerning this config pack:

https://github.com/KSP-CKAN/NetKAN/issues/1981

Just thought you might want to weigh in. :)

Basically, in CKAN it's listed with a "conflicts" rule against the "Interstellar Fuel Switch Core", which is breaking things for people who want to use this config in conjunction with other mods that require the Interstellar Core as a dependency. The "core" only adds the DLL, not any configs to stock tanks, so it's an unnecessary restriction. The Firespitter Core and Interstellar Core work together just fine.

Link to comment
Share on other sites

BTW, I noticed that the config adds the "FSfuelSwitch" module to all tanks, whether it has that already or not. Also, it's not also checking for "InterstellarFuelSwitch" modules either, which add the same functionality. I would suggest adding a "not" condition for both of these. For instance, this line:


@PART[*]:HAS[@RESOURCE[LiquidFuel],!RESOURCE[MonoPropellant],!RESOURCE[Oxidizer]] //bipropellant tanks

could be:


@PART[*]:HAS[@RESOURCE[LiquidFuel],!RESOURCE[MonoPropellant],!RESOURCE[Oxidizer],!MODULE[FSfuelSwitch],!MODULE[InterstellarFuelSwitch]] //bipropellant tanks

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 months later...
  • 2 months later...

I have some "useful" changer for this mod, maybe you found it useful too. Changes:

Spoiler

For regular liquidFuel/Oxidiser tank: LiquidFuel/Oxidzier,  LiquidFuel,  MonoPropellant.

For liquidFuel tanks:  LiquidFuel,  LiquidFuel/Oxidzier,  MonoPropellant.

For RCS tanks (why not?) MonoPropellant, Oxidizer (if someone need it, someone get it)

Put ElectricCharge in fuel tank - not the best idea, IMHO.

You still be the mod author i still play with my version, so if you prefer, you can update mod. Full code is in second spoiler, 

Code

Spoiler

@PART[*]:HAS[@RESOURCE[LiquidFuel],!RESOURCE[Oxidizer],!RESOURCE[MonoPropellant],!MODULE[FSfuelSwitch],!MODULE[InterstellarFuelSwitch]]:FINAL //jet fuel tanks
{
lforox = #$/RESOURCE[LiquidFuel]/amount$ //liquid fuel or oxidizer
lfifplusox = #$/lforox$ //liquid fuel if plus oxidizer
@lfifplusox *= 0.45
oxifpluslf = #$/lforox$ //oxidizer if plus liquid fuel
@oxifpluslf *= 0.55

@RESOURCE[LiquidFuel]
{
 @amount = 0
}

 MODULE
 {
 name = FSfuelSwitch
 resourceNames = LiquidFuel; LiquidFuel,Oxidizer; MonoPropellant
 resourceAmounts = #$/lforox$; $/lfifplusox$,$/oxifpluslf$; $/lforox$
 basePartMass = #$/mass$
 displayCurrentTankCost = false
 hasGUI = true
 availableInFlight = false
 availableInEditor = true
 showInfo = false
 }
 !lforox
 !lfifplusox
 !oxifpluslf
}




@PART[*]:HAS[@RESOURCE[LiquidFuel],@RESOURCE[Oxidizer],!RESOURCE[MonoPropellant],!MODULE[FSfuelSwitch],!MODULE[InterstellarFuelSwitch]]:FINAL //normal bipropellant tanks
{
lfifplusox = #$/RESOURCE[LiquidFuel]/amount$
oxifpluslf = #$/RESOURCE[Oxidizer]/amount$
lforox = #$/lfifplusox$
@lforox += #$/oxifpluslf$

@RESOURCE[LiquidFuel]
{
 @amount = 0
}
@RESOURCE[Oxidizer]
{
 @amount = 0
}

 MODULE
 {
 name = FSfuelSwitch
 resourceNames = LiquidFuel,Oxidizer; LiquidFuel; MonoPropellant
 resourceAmounts = #$/lfifplusox$,$/oxifpluslf$; $/lforox$; $/lforox$
 basePartMass = #$/mass$
 displayCurrentTankCost = false
 hasGUI = true
 availableInFlight = false
 availableInEditor = true
 showInfo = false
 }
 !lforox
 !lfifplusox
 !oxifpluslf
}





@PART[*]:HAS[!RESOURCE[LiquidFuel],@RESOURCE[MonoPropellant],!RESOURCE[ElectricCharge],!MODULE[FSfuelSwitch],!MODULE[InterstellarFuelSwitch]]:FINAL // RCS tanks
{
lforox = #$/RESOURCE[MonoPropellant]/amount$ //liquid fuel or oxidizer

@RESOURCE[MonoPropellant]
{
 @amount = 0
}

 MODULE
 {
 name = FSfuelSwitch
 resourceNames = MonoPropellant; Oxidizer 
 resourceAmounts = #$/lforox$; $/lforox$
 basePartMass = #$/mass$
 displayCurrentTankCost = false
 hasGUI = true
 availableInFlight = false
 availableInEditor = true
 showInfo = false
 }
 !lforox
}

 

Edited by Jenyaza
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...