Jump to content

Numerical Fuel Gauges (unfinished)


The_Duck

Recommended Posts

I was messing around with this at the request of semininja but I didn\'t quite get it working completely. If anyone wants to grab this code and run with it, feel free; I\'m not working on it at the moment.

This plugin provides an alternate command pod. When you use it in your ship it will add a numerical readout to the info boxes of fuel tanks:

JMpXO.png

The only problem is that it currently disrupts icon grouping: none of the fuel tank icons will group together, even when they aren\'t in use or are empty. I\'m not sure why this is; I haven\'t figured out how exactly the icon grouping is controlled.

Download here and unzip in your main KSP folder to install. The source is included, but I\'ll paste it here for easy viewing since it\'s short.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class ImprovedFuelGaugePod : CommandPod
{
Dictionary<FuelTank, VInfoBox> infoBoxes = new Dictionary<FuelTank, VInfoBox>();

protected override void onFlightStart()
{
foreach (Part p in this.vessel.parts)
{
if (p is FuelTank)
{
//clearing and recreating the info box seems to trick FuelTank into using our info box
//and this way we get a reference to the info box:
p.stackIcon.ClearInfoBoxes();
infoBoxes[(FuelTank)p] = p.stackIcon.DisplayInfo();
}
}

base.onFlightStart();
}

protected override void onPartFixedUpdate()
{
foreach (KeyValuePair<FuelTank, VInfoBox> pair in infoBoxes)
{
pair.Value.SetMessage('Fuel: ' + (int)pair.Key.fuel);
}

base.onPartFixedUpdate();
}
}

Link to comment
Share on other sites

I expect that probably wouldn\'t be too difficult, although I\'m not enough of a coder to even start to tell you how.

Also, here\'s a part that does this, which you can add to any rocket you\'ve already built.

Source is included. Model credit to NovaSilisko, code credit to The_Duck.

http://dl.dropbox.com/u/46530390/ImprovedFuelGauges.zip

Link to comment
Share on other sites

I expect that probably wouldn\'t be too difficult, although I\'m not enough of a coder to even start to tell you how.

Same goes for me. I imagine it may be a little tough to determine it by throttle. Anyways, just a question/suggestion. ;)

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