Created
March 19, 2020 18:13
-
-
Save DeltaDizzy/06f0bf09f51ae95a1bd551f072db0fa8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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