Jump to content

Module Multi Light


Jiraiyah

Recommended Posts

Hi everyone.

Stock KSP game has a ModuleLight. Let's have an example, think about a part that will sit on the surface of your vessle and behave like a mountable four direction light. Naturally you would have four spot lights in the modeling phase. You would like to turn all four of them on or off at the same time. Also, you would prefer to make all four lights blink at the same time. The stock ModuleLight, will only accept a single light geometry from your model. So, you would have to add four ModuleLights to your part file to handle all four spot lights. This will cause a huge headache for you. Using four ModuleLigths, means that now, in the part action window, you will have four buttons for turning lights on/off, and four buttons to make them blink. Unless you bind these actions to an action group, this won't work as intended. Also, now you would have four light color options. In some cases that is exactly what you need, then by all means, use the stock module. How ever, if you want to turn many light objects on/off and blink syncronously with a single button click, this little module is for you.

How to use

The syntax is similar to ModuleLight, how ever, when you have lightName in ModuleLight with a single name of the object, here you can have as many objects as you want, separate names with a comma and you can even use single space between comma and names to make things readable more. The final result will be something like this :

MODULE
{
	name = ModuleMultiLight
	lightName = light_obj_1, light_obj_2, light_obj_3, light_obj_4, light_obj_5, light_obj_6, light_obj_7, light_obj_8
	lightRange = 10;
	useAnimationDim = True
		animationName = ANIM_NAME_TURN_ON
		lightBrightenSpeed = 2.5
		lightDimSpeed = 2.5
	disableColorPicker = False
		toggleInEditor = True
		toggleInFlight = True
	canBlink = True
		blinkMin = 0.2
		blinkMax = 2.0
		blinkRate = 0.5
		isBlinking = False
	useResources = True
		resourceName = ElectricCharge
		resourceAmount = 0.002
}

Notic, beside having many object names, now you have one additional parameter that you can set, the light's range value! The default number for this value is set to 60. This default value would work properly in case you have one or two ligths, but with more lights in close space, you may want to tweak and nerf this value down like this example.

You can simply download the mod from SPACEDOCK

The source is published on GITHUB

Keep in mind, the license is MIT. If I was not able to keep this repo up to date in future for next versions of game, anyone who wants to maintain this, already have permission!

Version History :

1.12.5.1:

- Added the functionality for searching child objects for light, now, if you want, just put a single name (the parent) of the light object holders, the code will find all the children that are lights

- Added the slider for light range into the part action window both in editor and in flight

Known Bug : When you turn on the light on an active vessel and then leave it and go for other vessels, if you come back to the vessel, only the ring in colored and no lights are active, simply turn off the light (single light or on the whole vessel) and turn them back on, it should work. Unless someone can help me with this issue, no matter what I tried, nothing fixed this. If anyone can help with a pull request that would fix this issue, by all means please do it.

Edited by Jiraiyah
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...