Jump to content

[1.8+] Real Fuels


NathanKell

Recommended Posts

8 hours ago, blowfish said:

Did whoever added ModuleEngineConfigs to AJE engines actually test that the configuration works?

I'd be the whom, and it works in game. Configs are swapped as expected and change the engine properties. These errors only seem to appear during partload, I've not seem them thrown in-game and there doesn't appear to be any issues in-game. To my knowledge AJE-Extended is the only mod that uses Real-Fuels ModuleEngineConfigs and AJE engine modules together, so I tend to assume it's me screwing up somewhere.

I've looked through the source code for ModuleEngineConfigs and honestly can't really see where these errors might originate. The code seems to do a good job of checking for null objects before trying to do anything with them. My next step would probably be to compile RealFuels myself with debugging turned on and try and hunt down exactly what line is throwing the exception. It's just low on my to do list at the moment because:

  1. I've not done really any coding for KSP nor debugging, so would need to spend a fair bit of time learning before I could start,
  2. I simply don't have much time at the moment,
  3. It doesn't seem to actually cause any problems in-game.

Any way, I do want to delve in and try and solve this at some point, especially to find out if it's something that could be fixed my end. Or if there's some patch I can submit.

Link to comment
Share on other sites

@TranceaddicT

PartLoader warnings about variables can generally be ignored. It means that a field in the PART block of the config doesn't actually exist in the PART. Those fields are usually just for temporary data storage while the config is being built by whatever patch added it. Sometimes they get deleted in a later ModuleManager pass but it's not really a problem if they aren't.

 

As for the null ref, it sounds like it's only happening to the prefab and it's probably also safe to ignore that one but I'm not as confident in making that statement as for the variable warnings. I'll try to dig deeper but right now I'm thinking it's a configuration issue. I'd like to look at the configs in question.

Link to comment
Share on other sites

6 hours ago, Starwaster said:

@TranceaddicT

PartLoader warnings about variables can generally be ignored. It means that a field in the PART block of the config doesn't actually exist in the PART. Those fields are usually just for temporary data storage while the config is being built by whatever patch added it. Sometimes they get deleted in a later ModuleManager pass but it's not really a problem if they aren't.

 

As for the null ref, it sounds like it's only happening to the prefab and it's probably also safe to ignore that one but I'm not as confident in making that statement as for the variable warnings. I'll try to dig deeper but right now I'm thinking it's a configuration issue. I'd like to look at the configs in question.

That's what I figured was going on with the new variables.

I'm thinking that because the PART block doesn't have the variable 

TechLevels

When RF goes to 

resetTechLevels

it can't reaset a NaN and throws an error.

I'm just going to take a quick launch and stuff a TechLevel into AJEE_NapierLion_Prop.

Back in ~20m.

Link to comment
Share on other sites

10 hours ago, TranceaddicT said:

That's what I figured was going on with the new variables.

I'm thinking that because the PART block doesn't have the variable 


TechLevels

When RF goes to 


resetTechLevels

it can't reaset a NaN and throws an error.

I'm just going to take a quick launch and stuff a TechLevel into AJEE_NapierLion_Prop.

Back in ~20m.

No, a non-existent field in a PART config won’t affect RF/ MEC at all

Link to comment
Share on other sites

@TranceaddicT
The techlevels aren't relevant. Configs for normal engines work fine without them. They're only mentioned in the error log because techlevels is one of the parameters in the function throwing the exception.


@Starwaster
There's a lot going on with AJE-E configs, but I've picked out a bit of the relevant code for one of the parts throwing null refs:

It uses templates:

Spoiler

	 //Rolls-Royce Kestral (Interwar era 1920's-30s British V12)
	AJEE_RRKESTREL
	{
		author = Citizen247
			
		title = Rolls Royce Kestrel
		manufacturer = Rolls Royce
		description = A major V12 British aviation engine of the interwar period. The Kestrel Powered many RAF aircraft including the Hawker Fury, Britain's first 200mph+ fighter and the Hawker Hart.
		
		mass = 0.434
		//diameter = 1.0
		diameter = 1.125
		
		
		MODULE //Kestrel IB
		{
			name = ModuleEnginesAJEPropeller
			engineID = prop
			engineType = Piston
			
			IspMultiplier = 1
			useOxygen = true
			exhaustDamage = False
			ignitionThreshold = 0.1
	
			 //Settings based on R-1830, couldn't find anything solid so hoping that is close enough.
			displacement = 1300
			compression = 6.0
			minRPM = 500
			maxRPM = 2900
			power = 525
			gearratio = 0.553
			BSFC = 1.1E-7
			coolerEffic = 0
			coolerMin = -200
			ramAir = 0.15
			exhaustThrust = 0.0		
			meredithEffect = 0.0
			boost0 = 48
			rated0 = 4800
			boost1 = 0
			rated1 = 0
			cost1 = 50
			switchAlt = -1.0
			turbo = false
			wastegateMP = 48
			propName = 81in2CS
			
			#@AJEE_TEMPLATES/AJEE_CURVES/MIDPROP/atmosphereCurve {}
			#@AJEE_TEMPLATES/AJEE_CURVES/MIDPROP/velCurve {}
			#@AJEE_TEMPLATES/AJEE_CURVES/MIDPROP/atmCurve {}
															
			#@AJEE_TEMPLATES/AJEE_PROPFUEL/PROPELLANT {}
		}
	
		MODULE:NEEDS[RealFuels]
		{
			name = ModuleEngineConfigs
			type = ModuleEnginesAJEPropeller
			configuration = Rolls Royce Kestrel-IB
			useConfigAsTitle = true
			origMass = #$../mass$
			
			CONFIG
			{
				name = Rolls Royce Kestrel-IB
											
				massMult = 1		//434kg
				power = 525
				
				#@AJEE_TEMPLATES/AJEE_PROPFUEL/PROPELLANT {}
			}
			CONFIG
			{
				name = Rolls Royce Kestrel-V
											
				massMult = 1		//434kg
				power = 685
				
				#@AJEE_TEMPLATES/AJEE_PROPFUEL/PROPELLANT {}
			}
			CONFIG
			{
				name = Rolls Royce Kestrel-VI
											
				massMult = 1		//434kg
				power = 740
				
				#@AJEE_TEMPLATES/AJEE_PROPFUEL/PROPELLANT {}
			}
		}
	}

 

that are then inserted into "sanitised" part prefabs:

Spoiler

+PART[APP_Hawker_Prop]:NEEDS[AJE&AirplanePlus]:FOR[AJEEXTENDED]
{
	@name = AJEE_RRKestrel_Prop
	 //Part specific settings
}

@PART[AJEE_RRKestrel_Prop]:NEEDS[AJE]:FOR[AJEEXTENDED]
{
	@title = #$@AJEE_TEMPLATES/AJEE_RRKESTREL/title$
	@manufacturer = #$@AJEE_TEMPLATES/AJEE_RRKESTREL/manufacturer$
	@description = #$@AJEE_TEMPLATES/AJEE_RRKESTREL/description$
	@mass = #$@AJEE_TEMPLATES/AJEE_RRKESTREL/mass$
	
	@rescaleFactor = #$@AJEE_TEMPLATES/AJEE_RRKESTREL/diameter$
	@rescaleFactor /= #$/base_diameter$
	
	@category = Engine
	
	#@AJEE_TEMPLATES/AJEE_RRKESTREL/MODULE[ModuleEnginesAJEPropeller] {}

	@MODULE[ModuleEnginesAJEPropeller]
	{
		%thrustVectorTransformName = #$../AJEE_thrustTransformName$
	}
}

@PART[AJEE_RRKestrel_Prop]:NEEDS[AJE&RealFuels]:AFTER[AJEEXTENDED]
{
	#@AJEE_TEMPLATES/AJEE_RRKESTREL/MODULE[ModuleEngineConfigs] {}
}

 

This is what it looks like compiled in my modulemanager cache:

Spoiler

	parentUrl = AirplanePlus/Parts/Engine/Early/hawker/part.cfg
	PART
	{
		name = AJEE_RRKestrel_Prop
		module = Part
		author = blackheart612/Tanner Rawlings
		mesh = model.mu
		rescaleFactor = 0.9
		node_stack_top = 0.0, 0.0, 0.0, 0.0, -1.0, 0.0
		TechRequired = aviation
		cost = 400
		entryCost = 2200
		category = none
		subcategory = 0
		title = Rolls Royce Kestrel
		manufacturer = Rolls Royce
		description = A major V12 British aviation engine of the interwar period. The Kestrel Powered many RAF aircraft including the Hawker Fury, Britain's first 200mph+ fighter and the Hawker Hart.
		attachRules = 1,0,1,1,1
		mass = 0.434
		dragModelType = default
		maximum_drag = 0
		minimum_drag = 0
		angularDrag = 0
		breakingForce = 200
		breakingTorque = 200
		crashTolerance = 15
		maxTemp = 3600
		fuelCrossFeed = True
		bulkheadProfiles = size1
		base_diameter = 1.25
		AJEE_thrustTransformName = thrustTransform
		tags = aje_prop_engine
		MODULE
		{
			name = FSengineSounds
			engage = AirplanePlus/Sounds/hawker_startup
			power = AirplanePlus/Sounds/hawker_idle
			disengage = AirplanePlus/Sounds/hawker_stop
			flameout = AirplanePlus/Sounds/piston_flameout
			powerPitchBase = 0.8
			thrustAddedToPitch = 0.0
			powerFadeInSpeed = 0.003
			powerFadeInDelay = 0.5
			powerLowerThreshold = 0.0
			powerVolume = 1.0
			engageVolume = 1.0
			warningSoundThreshold = 0.8
			warningCooldownTime = 2.0
			randomStartDelay = 1.0
		}
		MODULE
		{
			name = ModuleAlternator
			RESOURCE
			{
				name = ElectricCharge
				rate = 1.0
			}
		}
		MODULE
		{
			name = FSplanePropellerSpinner
			propellerName = nosecone
			rotationSpeed = 400
			windmillRPM = 0.1
			spinUpTime = 0.175
			useRotorDiscSwap = 1
			rotorDiscFadeInStart = 0.95
			rotorDiscFadeInEnd = 0.95
			rotorDiscSpeed = 20
			rotorDiscName = disc
			blade1 = blade1
			blade2 = blade2
		}
		MODULE
		{
			name = FSswitchEngineThrustTransform
			defaultTTName = thrustTransform
			alternateTTName = alternatethrustTransform
			useNamedAlternate = 0
		}
		MODULE
		{
			name = FSengineHandCrank
		}
		MODULE
		{
			name = FMRS_PM
			parent_vessel = 0
		}
		MODULE
		{
			name = ControllingRecoveryModule
		}
		MODULE
		{
			name = ModuleSYPartTracker
		}
		MODULE
		{
			name = AlternatorFailureModule
			baseChanceOfFailure = 0.11
			expectedLifetime = 6
		}
		MODULE
		{
			name = TankFailureModule
			baseChanceOfFailure = 0.1
			expectedLifetime = 6
		}
		MODULE
		{
			name = ModuleEnginesAJEPropeller
			engineID = prop
			engineType = Piston
			IspMultiplier = 1
			useOxygen = true
			exhaustDamage = False
			ignitionThreshold = 0.1
			displacement = 1300
			compression = 6.0
			minRPM = 500
			maxRPM = 2900
			power = 525
			gearratio = 0.553
			BSFC = 1.1E-7
			coolerEffic = 0
			coolerMin = -200
			ramAir = 0.15
			exhaustThrust = 0.0
			meredithEffect = 0.0
			boost0 = 48
			rated0 = 4800
			boost1 = 0
			rated1 = 0
			cost1 = 50
			switchAlt = -1.0
			turbo = false
			wastegateMP = 48
			propName = 81in2CS
			thrustVectorTransformName = thrustTransform
			atmosphereCurve
			{
				key = 0 6500 0 0
			}
			velCurve
			{
				key = 0 0.9 0 8.335538
				key = 0.05 1.1 0.5928154 -1.385793
				key = 0.17 0.05 -27.85487 -3.821292
				key = 0.3 0.03 0 -1
				key = 0.4 0 0 0
			}
			atmCurve
			{
				key = 0 0 0 23.8846
				key = 0.2 2.235937 0.5522752 -0.8590934
				key = 0.525 1.025 0 0
				key = 1 0.8 0 0
			}
			PROPELLANT
			{
				name = AvGas
				resourceFlowMode = STAGE_STACK_FLOW_BALANCE
				ratio = 1
				DrawGauge = True
			}
		}
		MODULE
		{
			name = ModuleEngineConfigs
			type = ModuleEnginesAJEPropeller
			configuration = Rolls Royce Kestrel-IB
			useConfigAsTitle = true
			origMass = 0.434
			CONFIG
			{
				name = Rolls Royce Kestrel-IB
				massMult = 1
				power = 525
				PROPELLANT
				{
					name = AvGas
					resourceFlowMode = STAGE_STACK_FLOW_BALANCE
					ratio = 1
					DrawGauge = True
				}
			}
			CONFIG
			{
				name = Rolls Royce Kestrel-V
				massMult = 1
				power = 685
				PROPELLANT
				{
					name = AvGas
					resourceFlowMode = STAGE_STACK_FLOW_BALANCE
					ratio = 1
					DrawGauge = True
				}
			}
			CONFIG
			{
				name = Rolls Royce Kestrel-VI
				massMult = 1
				power = 740
				PROPELLANT
				{
					name = AvGas
					resourceFlowMode = STAGE_STACK_FLOW_BALANCE
					ratio = 1
					DrawGauge = True
				}
			}
		}
		MODULE
		{
			name = GeometryPartModule
		}
		MODULE
		{
			name = FARAeroPartModule
		}
		MODULE
		{
			name = FARPartModule
		}
		MODULE
		{
			name = KOSNameTag
		}
		MODULE
		{
			name = ModuleUPFMEvents
		}
	}

 

To see everything in context source is up on github:

https://github.com/seanyoung247/AJEExtended

If you need anything from me please let me know.

Edited by Citizen247
Link to comment
Share on other sites

  • 1 month later...

Is there a way to be able to copy and paste tank configurations (when in the VAB)? Obviously alt/option-click can copy it with the part but for a different tank I mean.

------------------------------

Also I think I'm having a bug in that when I fill a tank with a fuel, the GUI disappears, but in the PAW it still thinks it's active, so I have to click "Hide Tank UI" and then click "Show Tank UI" to be able to see it again. Then everytime I make an adjustment to the values it disappears again. I don't think it should disappear in the first place. It's especially tedious even when simply trying to manually split a tank in half for two different fuels.

If it's not a bug feel free to correct me. Here's log.

------------------------------

I've made a few patches; should they be made RealFuels side or on the side of the individual mod?

Edited by Iodyne
typo
Link to comment
Share on other sites

@Iodyne

No, you can't copy/paste tanks in the VAB

No, the tank window should not disappear when changing values and I have not seen that happen myself nor can I recall anyone having reported it before now. I'll look at your log.

Not sure what you mean about patches; please clarify that?

 

EDIT:

This is probably what is causing the window to vanish: 

[EXC 04:13:38.079] NullReferenceException: Object reference not set to an instance of an object
	RealFuels.Tanks.TankWindow.EnsureFreshAddLabelCache () (at <8f51b17657a546bc9d737ed47d61667b>:0)
	RealFuels.Tanks.TankWindow.GUITanks () (at <8f51b17657a546bc9d737ed47d61667b>:0)
	RealFuels.Tanks.TankWindow.GUIWindow (System.Int32 windowID) (at <8f51b17657a546bc9d737ed47d61667b>:0)
	UnityEngine.GUILayout+LayoutedWindow.DoWindow (System.Int32 windowID) (at <fa6f9762ac624af092525d37c9d516c4>:0)
	UnityEngine.GUI.CallWindowDelegate (UnityEngine.GUI+WindowFunction func, System.Int32 id, System.Int32 instanceID, UnityEngine.GUISkin _skin, System.Int32 forceRect, System.Single width, System.Single height, UnityEngine.GUIStyle style) (at <fa6f9762ac624af092525d37c9d516c4>:0)
	UnityEngine.DebugLogHandler:LogException(Exception, Object)
	ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
	UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

It looks like you don't have the latest version for KSP 1.8

Get RF 12.8.4.1

Edited by Starwaster
Link to comment
Share on other sites

6 hours ago, Starwaster said:

@Iodyne

No, you can't copy/paste tanks in the VAB

Okay thanks

6 hours ago, Starwaster said:

Not sure what you mean about patches; please clarify that?

Oh like a patch to make MkIVSystems and Luciole work. For some reason I figured RealFuels-Stock was more for engines and RealFuels for tanks (but I see there are some tank configs in RealFuels-Stock so I guess I should just put that there).

6 hours ago, Starwaster said:

 

 

It looks like you don't have the latest version for KSP 1.8

Get RF 12.8.4.1

Hmm it says I have 12.8.4.1; I could try a fresh install...

Link to comment
Share on other sites

  • 2 weeks later...

Hi, how to get the amount of remaining ignitions?

I tried this, but the the number doesn't change if the engine is turned on and off:

ModuleEngineConfigs engineConfigs = p.GetModule<ModuleEngineConfigs>();
if (engineConfigs!=null)
{
  Debug.LogWarning("engine ignition:"+ engineConfigs.config.GetValue("ignitions"));
}

 

Link to comment
Share on other sites

11 hours ago, Xavier513 said:

Hi, how to get the amount of remaining ignitions?

I tried this, but the the number doesn't change if the engine is turned on and off:


ModuleEngineConfigs engineConfigs = p.GetModule<ModuleEngineConfigs>();
if (engineConfigs!=null)
{
  Debug.LogWarning("engine ignition:"+ engineConfigs.config.GetValue("ignitions"));
}

 

That field isn't intended to store persistent engine status. You need to get the ignitions field from the engine itself. 

Link to comment
Share on other sites

10 hours ago, Starwaster said:

That field isn't intended to store persistent engine status. You need to get the ignitions field from the engine itself. 

Thanks, problem solved.

But I should look for remaining ignitions from "ModuleEnginesRF", not "ModuleEngines".

Link to comment
Share on other sites

23 hours ago, Xavier513 said:

Thanks, problem solved.

But I should look for remaining ignitions from "ModuleEnginesRF", not "ModuleEngines".

Right, I probably should have specified that but I thought it would be obvious that it was the RF extended engine

Link to comment
Share on other sites

I noticed the hsp for several items in the ResourceHsps file is 0 so I did some calculation using Engineer Equation Solver

hsp for LH2 is 12117 kJ/ton-K under 245 kPa and its saturated liquid(LH2 tank pressure for space shuttle is 32 - 39 psia so I took the intermediate value)

hsp for LOX is 1715kJ/ton-K under 25 psig (also for space shuttle) and LOX is saturated

hsp for liquid ammonia is 4567kJ/ton-K under 1 atm and saturated (I don't have any pressure data for ammonia powered rocket engines)

But specific heat is greatly dependent on pressure so when pressure changes, hsp changes a lot. So I'm not sure if this helps.

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 weeks later...
On 8/31/2020 at 3:16 AM, TranceaddicT said:

Not the binaries, it just has source code.

I tried to compile it (on 1.10.1 and 1.9.1) and I get this error

assembly/AssemblyInfoMFT.cs(20,28): error CS7034: The specified version string does not conform to the required format - major[.minor[.build[.revision]]]

I am not a developer, I am not sure what I am doing and I do not know what that means.

Link to comment
Share on other sites

I am trying to figure out where to go for compatibility between RF and other mods.
I read in this thread that in December 2014 support was added here for Nertea's Mark 4 spaceplane. But in my game it doesn't work for all MK4 parts.
It seems RF changes all parts that use IFS, while some MK4 parts seem to use ModuleB9PartSwitch. Could that be the issue? And who would update that? Or where do I find a crash course so I can do it myself? (I've tried before and RF/MM breaks my brain)

I have a similar issue with some US2 and Restock parts.

Edit: With some fiddling around and copy/pasting I managed to replace ModuleB9PartSwitch with ModuleFuelTanks. I added this to the top of RealFuels_MkIVSystem.cfg:
 

@PART[mk4*]:HAS[@MODULE[ModuleB9PartSwitch],!MODULE[ModuleFuelTanks],!MODULE[ModuleCommand]]:NEEDS[RealFuels]:FOR[zzzRealFuels]
{
	MODULE
  {
    name = ModuleFuelTanks
    volume = 0
    @volume = #$/MODULE[ModuleB9PartSwitch]/baseVolume$
    @volume *= 5
    type = Fuselage
  }
  
   !MODULE[ModuleB9PartSwitch] {}
}

This seems to work, but I haven't had time to fully test it yet.

Edited by boribori
epiphany
Link to comment
Share on other sites

@boribori couple of things you should pay attention to (not sure if it'll be a problem with those particular parts):

  1. There might be more than one ModuleB9PartSwitch on a part.  The patch you have will target the first one, which may or may not be correct.  You can be more specific by targeting by baseVolume > 0 or a specific moduleID
  2. If the different fuel subtypes have different visible meshes, they'll all show at once if you remove the module.

I made a crappy patch in B9 HX that tries to handle this.  It's not perfect though - for instance it doesn't handle the case that a structural subtype uses one mesh and multiple fuel subtypes use another.  Fundamentally you just have to look at every part and see what its requirements are.

Link to comment
Share on other sites

@blowfish yeah I noticed that my approach really messed up the meshes.
I finally settled for replacing the tank definitions with Kerosene, LqdOxygen and Hydrazine. But that's not good enough if I want to keep using RF.
I tried some @SUBTYPE and !tankType stuff earlier, but that didn't work at all. I probably made a mistake so I'll give it another try.
Thanks!

Link to comment
Share on other sites

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