Jump to content

[1.12.x] SimpleFuelSwitch v1.4.2: Toggle tanks' fuel type in the editor. Simple and lightweight.


Snark

Recommended Posts

3 hours ago, Tonka Crash said:

I'm ran into a devious little MM issue with the Add_LF_to_LFO_tanks.cfg and Add_LFO_to_LF_tanks.cfg patches.
...

  1. ...
  2. ...
  3. ...
  4. All patches without an ordering directive (:FIRST, :BEFORE, :FOR, :AFTER, :LAST, :FINAL) are applied. (SFS runs it's patches here, before I have a chance to run mine)
  5. For each item in the Unicode-sorted list of modname values:
    • All patches with :BEFORE are applied
    • All patches with :FOR are applied (SFS should run here)
    • All patches with :AFTER are applied

Wait, what?!?!  MM actually does "BEFORE" patches after the "I don't care when I'm run, no directive" patches?  Which part of "before" did it not understand?

Holy bug knuckles.  :confused:  I'm absolutely flabbergasted-- for one thing, that just seems wrong (clearly "before" should be before "I don't care"; this violates the Principle of Least Surprise all to heck); and, second, that I've managed to go this long without ever having the slightest inkling of that fact.  (Admittedly, I virtually never have reason to use the "BEFORE" tag-- usually it's "AFTER", if anything.  But still!)

Anyway, what I read from that is that BEFORE tags only work if everyone uses FOR tags for themselves.  Which means that any mod that does any MM patching at all must use the FOR directive in order to be a good citizen.

Okay, yeah, I gotta fix that.  (And in a zillion other places for all my mods... sigh.)  Oh well, live and learn.

Thanks for the heads-up, and I'll fix this when I can.

 

Link to comment
Share on other sites

@Snark I'm not used to looking at resources in tons and it bugged me enough to look in the code. 

For your consideration, I've made a change for the resource outputs. I'm not familiar enough with github to try to submit a change there, but here's a link to the one modified file. I've got a little extra bit of code that drops the decimal place in the resource amounts if the values are integers to keep the output tighter.

v8TyKLi.png

Link to comment
Share on other sites

1 hour ago, Tonka Crash said:

@Snark I'm not used to looking at resources in tons and it bugged me enough to look in the code. 

For your consideration, I've made a change for the resource outputs. I'm not familiar enough with github to try to submit a change there, but here's a link to the one modified file. I've got a little extra bit of code that drops the decimal place in the resource amounts if the values are integers to keep the output tighter.

Thanks, and that's a nice idea... actually I considered something like that when I was first writing the mod.  The problem is that it's not generally applicable.  Showing the number of resource units for an option doesn't work because in the general case, it's apples and oranges, if an option contains multiple resources.

Showing how many units of one resource makes sense.  But if there are multiple resources involved, it's apples and oranges.  For example, in your screenshot, your LFO option shows "400 units", which I presume is the sum of LF units and oxidizer units.  That may make mathematical sense for the specific case of LFO, since liquid fuel and oxidizer are the same number of kilograms for one unit, and they're consumed together, and the fuel tanks are designed so that the ratio of LF to O is exactly perfectly the ratio that engines consume.

But suppose the resource option was say, electricity plus monopropellant.  If there are 1000 units EC and 100 units monoprop, does it make sense to say there are 1100 total units?  For that matter, what if it contains 100 units LF and 1000 units xenon; saying "1100 units of resources" would be misleading.

Plus... even if it does make a certain amount of sense in the specific case of LFO... how is it useful to show the total units of the two?  I mean, the stock game never shows that anywhere-- it just shows LF and O numbers separately, and if a player wants to know "how many total units between the two", the player's gotta do some mental arithmetic.

And then there's what I keep coming back to, which is that for propellant resources, knowing the "units" is absolutely useless to me, because the only thing that's relevant for gameplay purposes is the mass of the resources-- that's what determines dV and is therefore what I care about.

Now, that's not to say that the mod might not benefit from some type of units-formatting attention, or ability to customize, and I may get around to doing that.  But the particular setup shown here is likely not how I'd go about it-- it would take the form of some sort of customizable config for formatting resource display in the panes at right.  I've already got some design ideas floating around in my mind, but prefer not to go into specifics at this time because such ideas have a way of morphing in the process of mulling them over, and I'd prefer not to set any false expectations.  ;)

Suffice to say is that my idea would most likely involve everything staying the way it is now by default, but that you'd have the option for reformatting stuff by tinkering with some config files (e.g. via MM), so that for your game you could make it look how you like.

Link to comment
Share on other sites

7 minutes ago, Snark said:

...

Suffice to say is that my idea would most likely involve everything staying the way it is now by default, but that you'd have the option for reformatting stuff by tinkering with some config files (e.g. via MM), so that for your game you could make it look how you like.

I'll look forward to what you come up with. In the meantime, I'll continue to play around with this in my game. I'm trying to keep my use of this mod "simple", so for now it's just a LF & LFO switcher for me with the default patches. But I like what you've done with TAC-LS to cut the part count. I need to examine that more closely to apply to a mod that has multiple sizes of different resource tanks that only differ in color.

Link to comment
Share on other sites

@Snark I went back and tweaked the output to split out multiple resources in the order they are in the internal arrays. This should be generic across any combination of resources, but I haven't tested to see what happens when the field is too narrow for the number of characters. Updated source file Just doing this update I found a bug in one of my patches. The maxAmount didn't agree with the base amount which showed up as two different values for Oxidizer in info screen.

The main reason I did this was that the MM issue I posted about yesterday took me longer to notice because I wasn't being presented the tank quantities in a form I was used to seeing when I switched to this mod, so I just didn't notice that one of the tanks I was using had half the fuel it should have. Just based on the name, you should know how many units of fuel should be in a cylindrical LFO tanks, but I have no idea about weights. If I used a calculator with the rocket equation it might be different, but for now I'll stick to KER doing the match for me.

Spoiler

Aj0qYyW.png

 

Link to comment
Share on other sites

4 minutes ago, Tonka Crash said:

@Snark I went back and tweaked the output to split out multiple resources in the order they are in the internal arrays. This should be generic across any combination of resources, but I haven't tested to see what happens when the field is too narrow for the number of characters. Updated source file Just doing this update I found a bug in one of my patches. The maxAmount didn't agree with the base amount which showed up as two different values for Oxidizer in info screen.

The main reason I did this was that the MM issue I posted about yesterday took me longer to notice because I wasn't being presented the tank quantities in a form I was used to seeing when I switched to this mod, so I just didn't notice that one of the tanks I was using had half the fuel it should have. Just based on the name, you should know how many units of fuel should be in a cylindrical LFO tanks, but I have no idea about weights. If I used a calculator with the rocket equation it might be different, but for now I'll stick to KER doing the match for me.

Thanks.  Unfortunately this approach won't scale:

hbdYHfV.png

There's very limited screen real estate.  It's suitable for displaying N things, but not N * M things, which is what this would be trying to do.

Consider the general case:

  • The "category label" might be something longer than "Fuel Type"
  • The display names of the selectable options might be something longer than "LF" or "LFO"
  • There could be an abitrarily large number of resources, and they might have bigger quantities involved.  For example, a large TAC-LS life supplies container would have to show units as "1557.5/1029.5/157669.8", which is way too long and way too much visual clutter even if it were formatted to leave off the decimal point.  What if a part has 10 different resources in it?

The fact is:  This part of the display was barely adequate for showing full info about every resource when there was just one set of resources to show.  With this mod, there could be N different selectable options, and showing all the info for all the options is just way too much "stuff".  It simply won't fit-- and even if it did fit, it is (by my definition, and my vote's the only one that matters) a cure worse than the disease, because to me it's a cluttery unreadable mass.  Anything that shows more than two or three numbers in one dense mass is just too cluttery for me.  (The above example has five numbers, in the best case scenario.)

So, any future change I make will very likely not include any sort of level of detail like this.  This is a spot of seriously premium real estate, and any information presented here needs to be ruthlessly summarized to the absolute bare-bones details.  I'm prepared to be mulishly stubborn on this point.

 

Now, this, on the other hand:
xtiQOv2.png

...there's plenty of screen real estate there, and it's visually separating the different selectable options onto different panes, so that's where it makes sense to have configurable formatting that shows whatever info one likes.  This is the place I'd be likely to focus my efforts.

 

17 minutes ago, Tonka Crash said:

Just based on the name, you should know how many units of fuel should be in a cylindrical LFO tanks

Nope.  Not consistent enough, not obvious enough, not the right place to have such information, and in any case it's all wrong because what I want to know about a tank is how many tons of fuel it contains, not how many units.  As far as I'm concerned, it's nice to have display names that are reasonably "informative" and consistent... but it's not a substitute for "real" information and so as far as I'm concerned the display name doesn't exist, except when I need to refer to a part by name when I'm posting in the forum.  ;)

Link to comment
Share on other sites

Hi gang,

I'm pleased to announce the release of SimpleFuelSwitch version 1.3.

New in this version:

  • Add new feature to allow customizing the format of resource display in the editor, via config. (Thanks to @Tonka Crash for suggesting.)
  • Update MM patches to appropriately use :FOR directives. (Thanks to @Tonka Crash for catching.)
  • Update to latest ModuleManager, 4.0.2. (Thanks to @RealKerbal3x for pointing out.)

The new customizable-resources-format feature is activated via config.  The default config that's installed with the mod simply sets up the behavior that you're all used to, which means if you simply update to this latest version of the mod and don't otherwise touch anything, you won't notice any change.  However, instead of being hard-coded and unchangeable, the behavior is now driven by config, so you can use a ModuleManager patch to adjust the way it looks.

For details about how the config works, please see the SimpleFuelSwitch.cfg file that's now installed with the mod.  Also, I've added a sample config patch to the "examples" folder in github (with lots of comments), to show how it's done.  The example patch makes the resources look the way @Tonka Crash was suggesting a couple of posts above.  So, Tonka, if you'd like it to look like that, all you have to do is grab the example patch and copy it to your GameData folder somewhere, and then it'll look like this:

K2aGifr.png

...note that the display has been customized to show units as well as mass.  The customization allows overriding the behavior on a per-resource-option basis (e.g. you could change all the LFO displays, but not other resources, if you were so inclined), or if you prefer you can override the default behavior that gets applied to everything.

Enjoy!  :)

Link to comment
Share on other sites

  • 4 weeks later...
19 minutes ago, Barzon Kerman said:

Can you add compatibility for ReStock/ReStock+?

I don't think SFS will need any work to make it compatible with Restock. It already automatically targets LFO tanks. However, if there are any LF-only tanks in Restock+ (I don't know, don't use RS/RS+ myself) then it will probably need a config.

Link to comment
Share on other sites

  • 1 month later...

@Snark While trying to debug something else I noticed I'm getting warnings from SFS:

[WRN 09:55:40.418] [SimpleFuelSwitch] No resources found for _default, returning null
[WRN 09:55:40.421] [SimpleFuelSwitch] No resources found for _default, returning null
[WRN 09:55:40.424] [SimpleFuelSwitch] No resources found for _default, returning null
[WRN 09:55:40.426] [SimpleFuelSwitch] No resources found for _default, returning null
[WRN 09:55:40.428] [SimpleFuelSwitch] No resources found for _default, returning null
[WRN 09:55:40.430] [SimpleFuelSwitch] No resources found for _default, returning null
[WRN 09:55:40.433] [SimpleFuelSwitch] No resources found for _default, returning null
[WRN 09:55:40.435] [SimpleFuelSwitch] No resources found for _default, returning null
[WRN 09:55:40.437] [SimpleFuelSwitch] No resources found for _default, returning null
[WRN 09:55:40.440] [SimpleFuelSwitch] No resources found for _default, returning null
[WRN 09:55:40.442] [SimpleFuelSwitch] No resources found for _default, returning null
[WRN 09:55:40.444] [SimpleFuelSwitch] No resources found for _default, returning null
[WRN 09:55:40.447] [SimpleFuelSwitch] No resources found for _default, returning null

I get this on some, but not all of my vessels on vessel load. What are these messages trying to tell me, i.e. what's the situation that causes this warning to be thrown? And, is it a problem? Sometimes it's just a couple, sometimes it's quite a few. 

Link to comment
Share on other sites

35 minutes ago, Tonka Crash said:

@Snark While trying to debug something else I noticed I'm getting warnings from SFS:

...

I get this on some, but not all of my vessels on vessel load. What are these messages trying to tell me, i.e. what's the situation that causes this warning to be thrown? And, is it a problem? Sometimes it's just a couple, sometimes it's quite a few. 

Huh.  I'm not getting that at all, myself.  Looking at the code, I can see where it's happening, but not clear to me why it's getting triggered in your case.  My guess is that what you're observing is the intersection between some brittle part of the mod (i.e. an edge case I didn't anticipate) with some specific use case you have that I never do (perhaps associated with what mods you're running).

I believe I can see what to do in the code to guard against it, but I'm a bit wary of releasing a "fix" for a problem that, 1. I can't reproduce myself, and 2. I don't actually know that it is a problem (e.g. does it actually affect the resources on your parts, or is it just a disturbing log message with no other effects).  Because any time I release a change, there's always the non-zero chance that I could break something, so I'm loath to touch anything unless I have definitive proof that it's needed and will provide an actual benefit.

Do you observe any in-game effects other than the log message itself?  (i.e. any parts where the resources appear to be wrong?)  Also, do you have a reliable repro case?  For example, is there some particular part that always causes this to happen?  (Even if it appears to be "harmless", i.e. just a spammy log message with no visible effects, it's still a wart that I'd like to fix, albeit less urgently than if it's causing actual problems.  But I'd need a repro case so that I could verify.)

Link to comment
Share on other sites

1 minute ago, Snark said:

Do you observe any in-game effects other than the log message itself?  (i.e. any parts where the resources appear to be wrong?)  Also, do you have a reliable repro case?  For example, is there some particular part that always causes this to happen?

I haven't noticed any issues which is why I haven't commented on it before. I first noticed it around the time 1.7 released because I was digging through the logs more often to track down bigger problems. I haven't figured out a specific case to isolate since it doesn't seem to be a problem. My first guess is that it might be related to old .craft files created before SFS existed, but I have spent absolutely no time trying to verify this. I was just wondering if you knew what it might be before I dug into it.

Link to comment
Share on other sites

8 minutes ago, Tonka Crash said:

I was just wondering if you knew what it might be before I dug into it.

Yep, no clue.

The craft where you observe this.  Do they have modded parts on them, or do you get it for .craft files that have only stock parts?

Link to comment
Share on other sites

Just now, Snark said:

Yep, no clue.

The craft where you observe this.  Do they have modded parts on them, or do you get it for .craft files that have only stock parts?

Like I said I haven't spent time trying to isolate it, so I can't really answer that. I run around 100 mods, so most of my craft probably have at least a couple mod parts on them, and if you add stock parts tweaked by MM patches I would have a hard time finding any craft that was bone stock with only SFS.  I try to stick to stock and near stock looking mods to flesh out the game without replacing the stock parts. The only mod I have that really seems to be misbehaving right now is Extraplanetary Launchpads. It has issues with the latest version of KAS and has yet to be updated for 1.7.

Link to comment
Share on other sites

  • 4 weeks later...

The evolution of how I thought about SFS:
1. Huh? Why does the fuel now show in mass instead of amount? How can I tell how much fuel is in there? EVERYTHING I know is based on amounts!
2. Hmm, I can adjust this CFG to show both the amount and mass.. Intredasting..
3. *time gaming passes*
4. Why on Kerbin don't all the other tanks just show the mass?! :0.0:

Just realized this and thought it was a funny enough tidbit to share. :D

Edit: With regards to choosing more fueltypes: Yes, there were a few times where I may have considered using it. No, I don't think it fits with the "Simple" bit. I like the simplicity and IMO it's better to KISS than to slowly bloat.


 

Edited by Jognt
Link to comment
Share on other sites

27 minutes ago, Daniel Prates said:

This would be even better if you could choose between LF+O, LF only, and Monoprop.

You may want to try my alternative config for SFS:

It allows you to enable/disable every stock fuel on every tank. By default, all fuel types are enabled but it can be easily changed in the configuration :)

Link to comment
Share on other sites

1 hour ago, Daniel Prates said:

This would be even better if you could choose between LF+O, LF only, and Monoprop.

Yah, this is one of those situations where there really isn't any one "right" answer because different people want different things.

For example.  You want monoprop as an option, because that's a convenience for you.  Makes perfect sense.

I, on the other hand, don't.  I don't mean "I don't need it" or "I don't care"; what I mean is I specifically want monoprop not to be an option and would be unhappy if it were.  That's because I actually like things to be a bit inconvenient.  I think of monoprop as being fundamentally different "stuff" than LF or LFO, and I like that it has its own dedicated set of specific fuel tanks and that it doesn't share space with the other stuff.  That forces me to design around it, which is a design challenge that I like.  Whereas the LF-LFO distinction is one that irritates me; I've always thought that both of those should have essentially all the same form factors of fuel tanks available.

That doesn't mean I'm asserting that my way is "right"... simply that it is, in fact, my way.  It's completely arbitrary and will differ from other people, but I like what I like, ditto you.

So "how are fuel tank options arranged" is one of those problems where things really do depend on individual tastes and there's really not going to be any one-size-fits-all "correct" answer for everybody.   Since pleasing everyone would be physically impossible, I simply set it  up to please myself, since, well, it's my mod.  :sticktongue:

That said, though, I do recognize that other people like different stuff than I do, and I'd like the mod to be generally useful and appealing to folks.  So I spent quite a bit of time when designing it to make sure that it's as flexible and config-driven as possible, so that someone who doesn't like the default behavior can easily customize it with a ModuleManager patch.

As, indeed, @4x4cheesecake has done here.  ;)

48 minutes ago, 4x4cheesecake said:

You may want to try my alternative config for SFS:

^ ...enabling that sort of thing is exactly why I put the configurability in there in the first place.

So, hopefully 4x4cheesecake's patch should get you the behavior you want.  And if not, you can always tweak a config patch yourself (and if you're having trouble figuring out how it works, hit me up and I'm happy to explain).

Link to comment
Share on other sites

@Snark Found a 1.7.1 bug.  Squad broke something with the way mods interacts with the PAW menu. I've seen a couple other comments about odd behavior and KAS is throwing exception in the PAW menu.  This one is just a nuisance, but if you can find a fix it might be a clue to what has to happen to fix other mods.

In the VAB just add a tank to a vessel and toggle the Fuel Type between LFO and LF a few times. You get a bunch of extra Oxidizer lines in the PAW menu. If you close the menu and reopen it, everything is looks like it should.

No errors are thrown. I've included the section of my KSP.log between adding the tank and taking the screenshot below. This is 1.7.1, all DLC and around 100 mods.

EDIT: Right after I posted I decided to rule out mod interaction. Clean install of 1.7.1 with no DLC and only SFS and Module Manager behaves exactly the same way in a new sandbox save.

kzC37Ek.png

Spoiler

[LOG 18:55:23.124] fuelTank added to ship - part count: 21
[LOG 18:55:24.677] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:55:35.305] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:55:40.154] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:55:42.538] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:55:44.421] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:55:45.309] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:55:46.305] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:55:46.916] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:55:55.788] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:55:56.369] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:55:57.671] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:55:58.195] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:55:59.388] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:56:00.053] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:56:03.464] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:56:04.379] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:56:05.657] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:56:06.292] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:56:07.429] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:56:08.096] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:56:09.152] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:56:09.847] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:56:10.819] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:56:11.374] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:56:12.486] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:56:14.046] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:56:15.076] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:56:15.604] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:56:18.663] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LF
[LOG 18:56:19.302] [SimpleFuelSwitch] Switched resources on fuelTank 3400203065 to LFO
[LOG 18:56:28.243] SCREENSHOT!!

 

 

Edited by Tonka Crash
Link to comment
Share on other sites

12 hours ago, Tonka Crash said:

In the VAB just add a tank to a vessel and toggle the Fuel Type between LFO and LF a few times. You get a bunch of extra Oxidizer lines in the PAW menu. If you close the menu and reopen it, everything is looks like it should.

Hm, interesting.  Yup, looks like something must have changed in the way the game handles the PAW.  From your description (i.e. the fact that it fixes itself when you close/reopen the PAW) it sounds like it's just a cosmetic issue, i.e. annoying but not actually adding multiple copies of the resource.

Thanks, I'll look into it as soon as I have time.  I happen to be unusually busy this month, so it might be a while before I can get to it, but I'll take a look as soon as I'm able.

Link to comment
Share on other sites

12 hours ago, Tonka Crash said:

Found a 1.7.1 bug.  Squad broke something with the way mods interacts with the PAW menu. I've seen a couple other comments about odd behavior and KAS is throwing exception in the PAW menu.  This one is just a nuisance, but if you can find a fix it might be a clue to what has to happen to fix other mods.

Happens in 'modular fuel tanks' too. You click to change fuel type, and it adds instead of changing. Obviously an issue caused by the new game version.

Link to comment
Share on other sites

7 minutes ago, Daniel Prates said:

Happens in 'modular fuel tanks' too. You click to change fuel type, and it adds instead of changing. Obviously an issue caused by the new game version.

Thanks, that's really useful to know!

Link to comment
Share on other sites

1 hour ago, Snark said:

Thanks, that's really useful to know!

Wait, a mistake from my part. It seems its 'fuel tank plus' and not 'modular fuel tanks' the mod  that ads a button, directly in the part UI, which is presenting an error similar to the one here.

I just installed modular fuel tanks and it has it's own separate UI, which works fine.

The thing thus could be related to the part context menu and how it relates to the part's configs, as mods that use it's own UI seem to be working fine. 

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