On Demand Fuel Cells (ODFC) by Orum

On Demand Fuel Cells (ODFC) by Orum

3.1k Downloads

[BUG 0.0.1.2b] Must have some EC to function, if EC == 0 does not charge

zer0Kerbal opened this issue ยท 4 comments

commented

[BUG 0.0.1.2b] Must have some EC to function, if craft EC == 0 does not charge

commented

outOfEC

commented

maybe changing if (cfTime == 0) to if (cfTime <= 0.25)?

or

if (Math.Round(cfTime, MidpointRounding.ToEven) == 0)

commented

I understand why fuel cells stop operating if vessel EC==0, also happens to stock - seems to be working as intended.

with vessel EC falls to zer0, everything electronic stops working. fuel cells are not mechanical, they require EC to function (even if a minuscule amount just to run the solenoids controlling fuel flow etc.)

So I believe this is working as intended, but should it be?

commented

fixed it.
just had to move two lines of code to execute earlier. Reason this works, why it wasn't working if vessel EC == 0 was the order of execution. Needed to add the generated EC before handling byproducts, and remove fuel which triggered update state.

This is the buggy code

	kommit(ODFC_config.modes[fuelMode].fuels, adjr);			// Commit changes to fuel used
	kommit(ODFC_config.modes[fuelMode].byproducts, adjr);		// Handle byproducts

	Double ECAmount = fuelModeMaxECRateLimit * cfTime;
	part.RequestResource(ElectricChargeID, -ECAmount);			// Don't forget the most important part

This is the corrected code:
```
Double ECAmount = fuelModeMaxECRateLimit * cfTime;
part.RequestResource(ElectricChargeID, -ECAmount); // Don't forget the most important part

kommit(ODFC_config.modes[fuelMode].fuels, adjr);			// Commit changes to fuel used
kommit(ODFC_config.modes[fuelMode].byproducts, adjr);		// Handle byproducts
![image](https://user-images.githubusercontent.com/39887717/63564071-14986580-c553-11e9-88a8-3acca8efa8ea.png)