Jump to content

Mod to make cabin lights consume EC?


fourfa

Recommended Posts

I did a little quick testing.  This can be done with a ModuleManager patch, but I need to figure out the detection logic and write the script.  I tested it by directly editing the Mk1 Command pod like so...

	//MODULE
	//{
	//	name = ModuleAnimateGeneric
	//	animationName = Mk1Lights
	//	defaultActionGroup = Light
	//	actionGUIName = Toggle Lights
	//	startEventGUIName = Lights On
	//	endEventGUIName = Lights Off
	//}
	MODULE
	{
		name = ModuleLight
		lightName = spotlight
		useAnimationDim = true
		lightBrightenSpeed = 2.5
		lightDimSpeed = 2.5
		resourceAmount = 0.04
		animationName = Mk1Lights
		useResources = true
	}

Give me a little bit and I'll figure out the module filter.  I just copied those values from the light parts and it seems to work ok.  Though I have no idea how much power they should actually consume.

Edited by Alshain
Link to comment
Share on other sites

Ok, well this is turning out to be more difficult than I thought.  Squad is nothing if not consistently inconsistent so the plane parts use a different module for the lights than the rocket parts.

These patches seem to work with the plane parts, I have to do some testing on the others.  I couldn't find a real good way to condense these into a single patch without running the risk of messing up a modded part so I opted to just keep them as separate patches.

// Add electric resource consumption to cockpit lights
// Author: Alshain

@PART[Mark1Cockpit] 
{
	@MODULE[ModuleAnimateGeneric]
	{
		@name = ModuleLight
		%useAnimationDim = true
		%lightBrightenSpeed = 2.5
		%lightDimSpeed = 2.5
		%resourceAmount = 0.01
		%useResources = true
	}
}

@PART[Mark2Cockpit] 
{
	@MODULE[ModuleAnimateGeneric]
	{
		@name = ModuleLight
		%useAnimationDim = true
		%lightBrightenSpeed = 2.5
		%lightDimSpeed = 2.5
		%resourceAmount = 0.01
		%useResources = true
	}
}

@PART[MK1CrewCabin] 
{
	@MODULE[ModuleAnimateGeneric]
	{
		@name = ModuleLight
		%useAnimationDim = true
		%lightBrightenSpeed = 2.5
		%lightDimSpeed = 2.5
		%resourceAmount = 0.01
		%useResources = true
	}
}

@PART[mk2Cockpit_Standard] 
{
	@MODULE[ModuleAnimateGeneric]
	{
		@name = ModuleLight
		%useAnimationDim = true
		%lightBrightenSpeed = 2.5
		%lightDimSpeed = 2.5
		%resourceAmount = 0.01
		%useResources = true
	}
}

@PART[mk2Cockpit_Inline] 
{
	@MODULE[ModuleAnimateGeneric]
	{
		@name = ModuleLight
		%useAnimationDim = true
		%lightBrightenSpeed = 2.5
		%lightDimSpeed = 2.5
		%resourceAmount = 0.01
		%useResources = true
	}
}

@PART[mk2CrewCabin] 
{
	@MODULE[ModuleAnimateGeneric]
	{
		@name = ModuleLight
		%useAnimationDim = true
		%lightBrightenSpeed = 2.5
		%lightDimSpeed = 2.5
		%resourceAmount = 0.01
		%useResources = true
	}
}

@PART[mk3Cockpit_Shuttle] 
{
	@MODULE[ModuleAnimateGeneric]
	{
		@name = ModuleLight
		%useAnimationDim = true
		%lightBrightenSpeed = 2.5
		%lightDimSpeed = 2.5
		%resourceAmount = 0.01
		%useResources = true
	}
}

@PART[mk3CrewCabin] 
{
	@MODULE[ModuleAnimateGeneric]
	{
		@name = ModuleLight
		%useAnimationDim = true
		%lightBrightenSpeed = 2.5
		%lightDimSpeed = 2.5
		%resourceAmount = 0.01
		%useResources = true
	}
}

 

Edited by Alshain
Link to comment
Share on other sites

Ok, well it looks like the other lights aren't going to work this way.  They use a module that actually changes the color of the 'glass' rather than using a model with a built-in animation.  A plugin is going to have to extend that color changing module in order to add a resource drain to it.

I'll take a look at making that plugin tomorrow.  I don't think it will be too difficult.

Edited by Alshain
Link to comment
Share on other sites

18 hours ago, fourfa said:

Wow, looking forward to it! Thanks

Ok, so the good news is I was able to quite easily extend ModuleColorChanger, the module that the rocket part lights uses.

The bad news is I had hoped to also extend ModuleAnimateGeneric that the cockpits use so I could charge them more cleanly, but so far I haven't found a way to detect if the animation is on or off (though I can detect the transition or "moving" as it is called in the code).  However, since the earlier patches I posted that convert it to ModuleLight seem to work ok you can just use that for now.  I'm just hoping there isn't a side effect of that I'm not aware of.

For ModuleColorChanger, I've written the rate, amount, and resource type in as public variables, so if there is another part using that module other than the cabin lights you could have it charge EC... or actually any resource... with a simple module manager patch and no change to the plugin.

I will probably go ahead and package this up in the next day or two as time permits and push it out for you.  I'll include the cockpit patches in the package as well.  It will likely appear in my modlet thread you see in my signature.

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