Jump to content

Stock Fuel Switch


Porkjet

Recommended Posts

Technically, if the two fuels are the same density, shouldn't you add the amounts together instead of doubling each one? For example, using the tank in the picture, the tank holds 180 LF and 220 Ox. Switching it to only LF would be like filling the Ox section with LF. So the tank would have a total of 400 Liquid Fuel. The same would be true of the Oxidizer.

Link to comment
Share on other sites

Technically, if the two fuels are the same density, shouldn't you add the amounts together instead of doubling each one? For example, using the tank in the picture, the tank holds 180 LF and 220 Ox. Switching it to only LF would be like filling the Ox section with LF. So the tank would have a total of 400 Liquid Fuel. The same would be true of the Oxidizer.

That's the exact point I was trying to make earlier in the thread...simply doubling the individual amount, the math does not add up. The stock tanks are set for the ratios needed to burn correctly, but when replacing fuels with just one type or the other, the only number that matters is the total tank size...ratio's don't come into play if there is no fuel mixture :)

Link to comment
Share on other sites

That's the exact point I was trying to make earlier in the thread...simply doubling the individual amount, the math does not add up. The stock tanks are set for the ratios needed to burn correctly, but when replacing fuels with just one type or the other, the only number that matters is the total tank size...ratio's don't come into play if there is no fuel mixture :)

Yeah.

If you look at the Mk3 short LFO tank its 14.29t wet with 1125 LF and 1375 O2

If you look at the Mk3 short LF tank its 14.29 wet with 2500 LF

and 2500 = 1125 + 1375, its not 2*1125 = 2250

Sticking with stock mechanics you'd add them up rather than doubling the LF.

It looks like the cost also goes up by a factor of 1.72 as well

- - - Updated - - -

Just to let you know, I installed this mod with a career save already in progress and found that, while the mod worked fine, all my existing ships in space had had their stock LF/O tanks magically refilled. (Admittedly, better than having them magically emptied!)

lol! confirmed.

Link to comment
Share on other sites

Yeah.

If you look at the Mk3 short LFO tank its 14.29t wet with 1125 LF and 1375 O2

If you look at the Mk3 short LF tank its 14.29 wet with 2500 LF

and 2500 = 1125 + 1375, its not 2*1125 = 2250

Sticking with stock mechanics you'd add them up rather than doubling the LF.

It looks like the cost also goes up by a factor of 1.72 as well

Here's a fixed version of Porkjet's "Hard coded" fuel tanks which preserves fuel density.


@PART[Size3LargeTank]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{



name = FSfuelSwitch

// the resources in each tank setup. Separate setups with a semicolon. Separate tanks

that go together in a single setup with a comma
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer

// the max amount of a resource in each tank in each setup. semicolons separate

setups, commas separate tanks in a setup
resourceAmounts = 6480,7920;14400;14400

// the dry mass of the part with no tanks
basePartMass =9

// each type of tank setup can weigh a different amount. Batteries should weigh more

than an empty LF tank. Some resources should require sturdy tanks.
//tankMass = 0;0;0

// Additional Funds cost for the different tanks. This is added to the part’s base

cost.
//tankCost =0;0;0

// If true, a line is added on the right click menu listing “Added Costâ€Â, because the

price widget in the editor is not updated often enough to make it obvious
displayCurrentTankCost = false


// Whether the player can affect the tank setup selection directly, or must do it

through a mesh or fuel switcher.
hasGUI = true

// If true, the user can switch resource types while playing. This will empty out the

tank. Makes sense for converting a tank from LiquidFuel to Kethane after landing a mining base for

instance. Default is off of course.
availableInFlight = false

// Is the player allowed to set up the tank in the hangar? In the above scenario,

maybe you don’t want that.
availableInEditor = true

// If true, it feeds info to the module info system that appears when you righ click

a part in the part catalog in the hangar. In sets of mesh switchers and fuel switchers, you will want

to turn this off in one of them
showInfo = true
}

}
@PART[Size3MediumTank]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 3240,3960;7200;7200
basePartMass =4.5
//tankMass = 0;0;0
//tankCost =0;0;0
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}
@PART[Size3SmallTank]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 1620,1980;3600;3600
basePartMass =2.25
//tankMass = 0;0;0
//tankCost =0;0;0
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}

@PART[fuelTank3-2]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 2880,3520;6400;6400
basePartMass =4
//tankMass = 0;0;0
//tankCost =0;0;0
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}

@PART[fuelTank1-2]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 1440,1760;3200;3200
basePartMass =2
//tankMass = 0;0;0
//tankCost =0;0;0
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}

@PART[fuelTank2-2]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 720,880;1600;1600
basePartMass =1
//tankMass = 0;0;0
//tankCost =0;0;0
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}

@PART[fuelTank4-2]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 360,440;800;800
basePartMass =0.5
//tankMass = 0;0;0
//tankCost =0;0;0
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}
@PART[fuelTankSmallFlat]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 45,55;100;100
basePartMass =0.0625
//tankMass = 0;0;0
//tankCost =0;0;0
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}
@PART[fuelTankSmall]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 90,110;200;200
basePartMass =0.125
//tankMass = 0;0;0
//tankCost =0;0;0
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}
@PART[fuelTank]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 180,220;400;400
basePartMass =0.25
//tankMass = 0;0;0
//tankCost =0;0;0
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}
@PART[fuelTank_long]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 360,440;800;800
basePartMass =0.5
//tankMass = 0;0;0
//tankCost =0;0;0
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}
@PART[toroidalFuelTank]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 27,33;60;60
basePartMass =0.0375
//tankMass = 0;0;0
//tankCost =0;0;0
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}
@PART[miniFuelTank]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 18,22;40;40
basePartMass =0.025
//tankMass = 0;0;0
//tankCost =0;0;0
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}



//MK2///////////////////////////////




@PART[mk2_1m_Bicoupler]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 180,220;400;400
basePartMass =0.29
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}
@PART[mk2_1m_AdapterLong]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 360,440;800;800
basePartMass =0.57
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}
@PART[mk2SpacePlaneAdapter]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 180,220;400;400
basePartMass =0.29
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}

//MK3/////////

@PART[adapterMk3-Mk2]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 900,1100;2000;2000
basePartMass =1.43
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}
@PART[adapterMk3-Size2]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 1125,1375;2500;2500
basePartMass =1.79
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}

@PART[adapterMk3-Size2Slant]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 1125,1375;2500;2500
basePartMass =1.79
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}
@PART[adapterSize2-Mk2]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 360,440;800;800
basePartMass =0.57
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}
@PART[adapterSize2-Size1]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 360,440;800;800
basePartMass =0.57
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}
@PART[adapterSize2-Size1Slant]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 360,440;800;800
basePartMass =0.57
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}
@PART[adapterSize3-Mk3]
{
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{

name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = 1125,1375;2500;2500
basePartMass =1.79
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}

}

Badsector's solution is much more elegant, though neither Badsector nor Nertea's code calculate the dry cost of the fuel tanks correctly.

- - - Updated - - -

Actually neither does Porkjet's now that I look at it.

fuelTank1-2 costs 3000 full. 1440 liquid fuel + 1760 oxidizer. Liquid fuel costs 0.8 per unit and has a density of 0.005, oxidizer costs 0.18 per unit and has a density of 0.005. The derived fuelTank1-2 dry cost is therefore 3000-1152-316.8=1531.2, which should be the "stock" cost of the tank.

1440*0.005=7200kg of liquid fuel, 1760x0.005=8800kg of oxidizer, or 3200 units of 0.005 density fuel. Badsector and Nertea cfgs calculate these correctly.

But. Dry cost of LF+Ox=1531.2, Dry cost of LF only is 3000-(3200*.8)=440 dry tank cost. That's cheap. Ox is 3000-(3200*.18)=2424 expensive tank.

The problem is these functions are looking at the tanks as their stock full cost (with lf+ox).

Link to comment
Share on other sites

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

%LF = #$RESOURCE[LiquidFuel]/maxAmount$
%OX = #$RESOURCE[Oxidizer]/maxAmount$

%totalCap = #$RESOURCE[LiquidFuel]/maxAmount$
@totalCap += #$RESOURCE[Oxidizer]/maxAmount$

%tempVar = 0
%dryCost = 0

@dryCost = #$cost$

%LFCost = 0
%OXCost = 0
%mixLFCost = 0

// 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;Oxidizer


resourceAmounts = #$../LF$,$../OX$;$../totalCap$;$../totalCap$


tankCost = #$../mixLFCost$;$../LFCost$;$../OXCost$
displayCurrentTankCost = true


hasGUI = true
showInfo = true

availableInFlight = false
availableInEditor = true


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

!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}

}

Updated version using Badsector & Nertea's code, calculates cost correctly, uses firestarter. LF+OX, LF, OX variations only.

Link to comment
Share on other sites

Emm, what do with that code? Replace in .cfg or paste under origin code?

Make sure you don't already have a fuel switcher cfg somewhere else, and just copy/paste it into a cfg file and put it anywhere in your GameData folder. I usually keep mine in a subfolder inside of the actual FuelSwitcher DLL folder, helps me keep track of where it's at :)

I think if you have more that one cfg file for a fuel switcher, they'll all get run and things will get complicated. Not to mention that annoying habit of fuel tanks resetting every time you do switch cfgs :)

Link to comment
Share on other sites

Yeah, pretty much. Personally, on my installation I replaced Porkjet's .cfg with that code. Haven't noticed any bugs so far. Hopefully Porkjet will include it in a future update.

Ah, one noticeable change is that the part list now displays the dry weight cost of fuel tanks instead of full.

Edited by veryinky
Link to comment
Share on other sites

Yeah, pretty much. Personally, on my installation I replaced Porkjet's .cfg with that code. Haven't noticed any bugs so far. Hopefully Porkjet will include it in a future update.

Ah, one noticeable change is that the part list now displays the dry weight cost of fuel tanks instead of full.

Did you have any existing crafts in orbit? I think it's a game mechanic, or MM mechanic that auto-refills any existing tanks when a new FS patch is applied. Just wondering if yours did that to you as well. I'm putting off switching to your cfg until I finish up this ridiculous mission I'm in the middle of, but I like the look of your cfg file!

Link to comment
Share on other sites

Did you have any existing crafts in orbit? I think it's a game mechanic, or MM mechanic that auto-refills any existing tanks when a new FS patch is applied. Just wondering if yours did that to you as well. I'm putting off switching to your cfg until I finish up this ridiculous mission I'm in the middle of, but I like the look of your cfg file!

I tested it with a ship in orbit and an empty tank (+pod) on the launchpad. Neither refilled. Not sure how to replicate that bug.

Link to comment
Share on other sites

I tested it with a ship in orbit and an empty tank (+pod) on the launchpad. Neither refilled. Not sure how to replicate that bug.

Right on. Just put your cfg in, and you're right, it leaves existing tanks as they are. You changed something, because virtually every cfg I tried would reset the tanks...

Thanks, whatever the change was, I like it :)

Link to comment
Share on other sites

  • 2 weeks later...

I replaced the entire config with Veryinky's clever code.

It creates even amounts of fuel for the LF/OX-only versions, which seems to be what the majority of you want so I'm fine with that.

As of this version this mod is entirely a compilation of other peoples work, which feels kinda cheaty, heh.

Link to comment
Share on other sites

It creates even amounts of fuel for the LF/OX-only versions, which seems to be what the majority of you want so I'm fine with that.

Is there a way to change that, for the minority of us who don't want it that way?

As of this version this mod is entirely a compilation of other peoples work, which feels kinda cheaty, heh.

Anyway it was your initial idea, you know, it is the thought that counts. :)

Link to comment
Share on other sites

That's what the script does now, it removes all the fuel from the tank, calculates the dry cost of the tank, then allows you to add 100% lf, 100% oxy, or 0.9/1.1 ratio lf/ox. Porkjet's gif on the op page is out of date.

Link to comment
Share on other sites

One small thing, for example, the SDHI Service Module contains LF+OX+Monoprop.

After using this up to date MM-Patch all the Monoprop is gone.

I assume its the same for other multifunctional Tanks like the one of "Near Future [insert some suffix here]".

Is there a way to prevent the loss of Monoprop with using this?

Link to comment
Share on other sites

I just noticed that I'm getting part errors when using Veryinky's cfg. Everything seems to work just fine in the game, but I just wanna make sure the errors aren't important. Can someone look at this and see?

Seems like they are all errors having to do with the variables, MixLFCost, LF, OX tempvar, totalcost. etc etc

Player.log

Link to comment
Share on other sites

  • 2 weeks later...

Hey^, why don't you just drop the simple .dll into your gamedata folder and enlighten everybody who uses this mod?

Thanks for all the work OP - i might be able to find a use for the Nerv with this.

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