Skip to content

Instantly share code, notes, and snippets.

@DeltaDizzy
Created March 19, 2020 18:13
Show Gist options
  • Save DeltaDizzy/06f0bf09f51ae95a1bd551f072db0fa8 to your computer and use it in GitHub Desktop.
Save DeltaDizzy/06f0bf09f51ae95a1bd551f072db0fa8 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NeverBasicTweaks
{
class PowerWarningTestModule : PartModule
{
[KSPField]
public string engineModuleID;
ModuleEngines engine;
public double requiredPower;
public override void OnStart(StartState state)
{
engine = part.FindModulesImplementing<ModuleEngines>().Find(m => m.engineID == engineModuleID);
requiredPower = engine.propellants.Find(p => p.name == "ElectricCharge").currentRequirement;
}
void FixedUpdate()
{
vessel.GetConnectedResourceTotals(PartResourceLibrary.ElectricityHashcode, out double amount, out double maxamount);
if (engine != null && amount < requiredPower)
{
ScreenMessages.PostScreenMessage($"You don't have enough electricity to run the engine! You have {amount}, but you need {requiredPower}");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment