Jump to content

Make custom engine propellant


Recommended Posts

I'm trying to create a custom propellant for engine modules on parts such as photon sails. I called the resource 'Photons', and created a Resource Definition for it. For some reason when I make an engine consume this custom resource, the engine breaks completely (the right-click menu stops working and the log file shows errors to do with it not finding a propellant resource definition).

Here is the resource definition:

RESOURCE_DEFINITION
{
	name = Photons
	displayName = Photons
	abbreviation = γ
	density = 0.001
	unitCost = 0.001
	flowMode = STACK_PRIORITY_SEARCH
	transfer = PUMP
	isTweakable = true
	isVisible = true
	volume = 5
}

Is there an extra parameter I have to add to make it an engine propellant? And yes I tried to make LiquidFuel the propellant for that engine instead, and it works perfectly. I also tried adding hsp and vsp parameters and that still didn't work.

Thanks.

Link to comment
Share on other sites

11 hours ago, Aniruddh said:

I'm trying to create a custom propellant for engine modules on parts such as photon sails. I called the resource 'Photons', and created a Resource Definition for it. For some reason when I make an engine consume this custom resource, the engine breaks completely (the right-click menu stops working and the log file shows errors to do with it not finding a propellant resource definition).

Here is the resource definition:


RESOURCE_DEFINITION
{
	name = Photons
	displayName = Photons
	abbreviation = γ
	density = 0.001
	unitCost = 0.001
	flowMode = STACK_PRIORITY_SEARCH
	transfer = PUMP
	isTweakable = true
	isVisible = true
	volume = 5
}

Is there an extra parameter I have to add to make it an engine propellant? And yes I tried to make LiquidFuel the propellant for that engine instead, and it works perfectly. I also tried adding hsp and vsp parameters and that still didn't work.

Thanks.

Not sure if its the problem but you are missing 

hsp =

And also see that stock added a 

  RESOURCE_DRAIN_DEFINITION
  {
	isDrainable = true
	showDrainFX = true
	drainFXPriority = 7
	drainForceISP = 5
	drainFXDefinition = gasDraining
  }

or 

  RESOURCE_DRAIN_DEFINITION
  {
	isDrainable = false
	showDrainFX = false
  }
RESOURCE_DEFINITION
{
  name = ElectricCharge
  displayName = #autoLOC_501004 //#autoLOC_501004 = Electric Charge
  abbreviation = #autoLOC_6002100 //#autoLOC_6002100 = EC
  density = 0
  unitCost = 0
  hsp = 0
  flowMode = STAGE_PRIORITY_FLOW
  transfer = PUMP
  isTweakable = true
  RESOURCE_DRAIN_DEFINITION
  {
	isDrainable = false
	showDrainFX = false
  }
}

 

Edited by Mecripp
Link to comment
Share on other sites

@Aniruddh Try not using exotic characters in the config. Your value for abbreviation should be the trigger. The Community Resource Pack had an enormous crap storm for a time due to, I'm pretty sure, exactly this (abbreviations in exotic languages having only one character).

Angel-125's Classic Stock resources don't have all that drain valve stuff in them and that absence doesn't break KSP.

Related note: The abbreviation value only shows up in KerbNet's resource overlay selector (which is only useful for crustal mined resources). I'm pretty sure no mod uses it so it's not important that you have that key in this definition.

Link to comment
Share on other sites

Both of those points make sense and should've worked, but it still comes up with the same errors. I also just now noticed the engine I make consume the Photons resource, it's thrust becomes trillions of kN. It also spams the log file with Nullref exceptions.

Link to comment
Share on other sites

@Aniruddh I've tried your unedited patch and found no problem. This tells me that your patches, outside of your resource definition, are broken somewhere.

My config:

RESOURCE_DEFINITION
{
	name = Photons
	displayName = Photons
	abbreviation = γ
	density = 0.001
	unitCost = 0.001
	flowMode = STACK_PRIORITY_SEARCH
	transfer = PUMP
	isTweakable = true
	isVisible = true
	volume = 5
}

// Terrier
@PART[liquidEngine3_v2]
{
	@MODULE[ModuleEngines*]
	{
		@PROPELLANT[LiquidFuel]
		{
			@name = Photons
			@ratio = 1
		}
		!PROPELLANT[Oxidizer] {}
		@atmosphereCurve
		{
			!key,* = nope
			key = 0 90000
			key = 0.1 0.001
		}
	}
	RESOURCE
	{
		name = Photons
		amount = 50000
		maxAmount = 50000
	}
}

0xCmZ1M.png

Side note: 50 tons. Holy crap. I think 1kg per unit of "Photons" is pretty excessive (objectively speaking). I'd divide this density by 1000 and preserve some more of the emphasis of being a near-massless resource. And I'd expect that any engine that uses this would only hold as much as possible for a few seconds of burn time assuming the beamed power connection suddenly dropped.

Edited by JadeOfMaar
Link to comment
Share on other sites

35 minutes ago, JadeOfMaar said:

I've tried your unedited patch and found no problem. This tells me that your patches, outside of your resource definition, are broken somewhere.

You're right, using the photons resource to power an engine on its own works perfectly. I commented out a few lines of code in my plugin (which had a part module controlling the engine module) and it still worked perfectly so these were the problem. 

These lines were:

double fuel_rate = engines.maxThrust * 1000 / (9.81 * engines.realIsp);
string fuelname = engines.propellants[0].name;
this.part.RequestResource(fuelname, -fuel_rate * Time.fixedDeltaTime);

I was thinking of replenishing the photons resource, but yeah then again, the consumption rate is tiny. I could just replenish the resource when it actually runs out rather than every frame.

And yes the density is huge, since I had just copy-pasted the resourcedef for Ablator.

Anyways thanks for testing this so thoroughly!

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