Li0n

(Drop Support)[1.6.1] Crew Light : An Automatic Light Manager [v1.19] (29 Jan 2019)

Recommended Posts

Hi fellow kerbonauts

After years of downloading and enjoying mod from the great KSP community it's time I do something myself, so here it is : Crew Light

The goal of this mod is to automatize, as much as possible, the lights of your vessels (and of kerbal's helmet).

 

Every part that currently hold crew gets its lights turning on

GIF of the crew transfer

 

Lights react to the sunshine

GIF of Sunlight

 

 

And to depth

GIF incoming...

 

When approaching a distant vessel its lights will blink, sending you a welcoming message in Morse code

GIF of MorseLight

 

Kerbal on EVA can toggle lights

GIF of EVAToggleLight

 

Lights can have a motion detector set up

M0n02ZM.gif

MmYwl2Y.gif

 

 

Youtube review by @Kottabos :

 

How does it works ?

Vessel's lights are divided into 3 groups :

  • Lights of crew-able part :
    • They will remain off until a kerbal gets on-board
  • Lights NOT in the light action group : (and kerbal's helmet light)
    • They'll go on when the sun's fall, off when it rises
  • Other Lights :
    • They will work as usual, toggling by the light action group

This mod rely on the light action group to determine which light belongs to which group, in stock KSP you can change action group only in the editor, so no lights on all crafts already launched will react to the sun rising/falling. To change action group in flight you will need the mod Action Groups Extended, by @Diazo.

And an enhanced support of the mod Aviation Lights by @BigNose, maintained by @MOARdV :

  • By default its navigation and strobe light will get turned on at night using the custom blinking light provided by AviationLights, flash, double flash, interval. This is configurable, per light, in the setting file.
  • The beacon light will stay off until you push the throttle, acting as a real warning light

And it now support Kerbal Electric (a set of tweak-able and very cool lights) :

How to modify how it works ?

Most of the function can be disabled, or tweaked, directly from the in-game settings screen :
 
1OoqY7n.png
 
There's also some extra option for the Morse Code message.
 
z8QINGo.png
 
Due to limitation of the stock settings menu (or limitation to my modding skill :p ) it's a bit tricky to access it : in the settings screen enable the "More Morse Settings", hit accept, twice, and you got it.
 
N8tFWe0.png

Here you can change the morse message send by distant vessel as you approch them. And the timing for the different symbol (they are sync to the dit duration unless you check manual timing).

 

What is needed ?

ModuleManager is the only dependency, all credits go to @ialdabaoth and @sarbian

 

Know issues :

Lights on kerbal's helmet don't turn on/off as the sun rises/falls. Lights will be turned on if the kerbal disembark in the dark but status of the sunlight won't be checked after that.

The range sphere of the Motion Detector is offset from the light position only for the stock light, for others the sphere center is at the light position.

 

What to do if it doesn't work ?

Report it to Github or on this thread.

 

This is my first mod for KSP and one of my first working C# code, I've tested it on every situation I could think of but it may have bugs left.

 

And a big thank you to @Diazo, @Nereid, @Crzyrndm, @RealGecko, @Skalou for helping me, and to every modders out there who wrote good code for learning :) 

 

Download on SpaceDock

Download on Github

Last 1.5.1 version

Last 1.4.3 version

Last 1.4.2 version

Last 1.4.1 version

Last 1.4.0 version

Last 1.3.1 version

Last 1.3 version

Last 1.2.2 version

Source on Github

License is MIT

Dev thread, now closed

Edited by Li0n

Share this post


Link to post
Share on other sites

Very cool idea, the blinking when approaching stuff.

Cheers commander!

Share this post


Link to post
Share on other sites

@Climberfx Thank you very much :)

 

It should be available on CKAN not before long, my PR has just passed the test.

Share this post


Link to post
Share on other sites
1 minute ago, RealGecko said:

I like this Morse code blinking, really cool!

You're welcome, thanks again for the idea of the lights responding to the sunshine, now the coolest part of the mod IMO.

Share this post


Link to post
Share on other sites
Just now, Li0n said:

You're welcome, thanks again for the idea of the lights responding to the sunshine, now the coolest part of the mod IMO.

And I liked the idea of Morse code, that's why I suggested autolights to you instead of writing JAKSPM :D:D:D

Share this post


Link to post
Share on other sites

Seems like a good quality of life mod. Might get added to my stock save.

Share this post


Link to post
Share on other sites

Can you detect if a kerbal is in shadow? I like to turn on the helmet lights if I'm working in the shadows, in orbit or on the surface.

Share this post


Link to post
Share on other sites
1 hour ago, ioresult said:

Can you detect if a kerbal is in shadow? I like to turn on the helmet lights if I'm working in the shadows, in orbit or on the surface.

Yes and no : depends on where the shadows are coming from, shadow from terrain/planet/moon are detected but those from vessels are not.

And helmet's light won't be updated while on EVA, I couldn't figure out how to make it working while time-warping so I disabled it. They are toggled on/off depending on the sun only when a kerbal disembark (and when (re-)loading a save).

Personally I like to have them always on while in space (because you know, space is dark and full of terrors :wink: ). always_on_in_space = True do that automatically (False by default).

Share this post


Link to post
Share on other sites

This mod has passed the test! Aaaand now it's allowed to stay in my heavy GameData folder :wink:

Kongrats with your first mod, and also Kongrats cos' it was just reviewed by Kottabbo:D

 

Edited by Dr.Wolfram
link correction

Share this post


Link to post
Share on other sites
23 minutes ago, Dr.Wolfram said:

This mod has passed the test! Aaaand now it's allowed to stay in my heavy GameData folder :wink:

Kongrats with your first mod, and also Kongrats cos' it was just reviewed by Kottabbo:D

 

Thanks :):):) to you and to @Kottabos for the review, that was quick :wink: (actually the first version of the mod is from October 21, a little more than 3 hours ago :wink: ).

In the review/beta-testing you noticed some issues :

  • The lights who respond to the sun are toggled too late : I'm worried about performance so I check for the sun position every 1.5s, it feels good without time-warp but I agree it feels off at high time-wrap, I can expose the settings for the delay easily but it would be better to change the delay to 0.1s or so when in time-warp.
  • Lights get added back to action group when reloading a ship in the editor : good catch, I've done most of my test with AGX installed so I may have missed something for stock game, or is it a stock bug ?
  • Toggling lights while on EVA toggle all symmetrical lights : I wanted to take care of that before release but completely forgot, will do.
  • Lights related to the sun light go off on the middle of the night : I'm pretty sure you lack proper battery (happened to me numerous time during development, RTG is your friend :wink: )
  • Morse Code isn't a proper message : Actually it is, but the delay for the "ti" and the "taah" are too close, it's configurable but I'll change the default setting.

Thanks again and please keep reporting bug / suggestion / feedback :)

Share this post


Link to post
Share on other sites

Can the dusk/dawn light toggle be slightly randomized, so that not all the lights turn on at the exact same time?

Share this post


Link to post
Share on other sites
13 hours ago, Li0n said:

Thanks :):):) to you and to @Kottabos for the review, that was quick :wink: (actually the first version of the mod is from October 21, a little more than 3 hours ago :wink: ).

In the review/beta-testing you noticed some issues :

  • The lights who respond to the sun are toggled too late : I'm worried about performance so I check for the sun position every 1.5s, it feels good without time-warp but I agree it feels off at high time-wrap, I can expose the settings for the delay easily but it would be better to change the delay to 0.1s or so when in time-warp.
  • Lights get added back to action group when reloading a ship in the editor : good catch, I've done most of my test with AGX installed so I may have missed something for stock game, or is it a stock bug ?
  • Toggling lights while on EVA toggle all symmetrical lights : I wanted to take care of that before release but completely forgot, will do.
  • Lights related to the sun light go off on the middle of the night : I'm pretty sure you lack proper battery (happened to me numerous time during development, RTG is your friend :wink: )
  • Morse Code isn't a proper message : Actually it is, but the delay for the "ti" and the "taah" are too close, it's configurable but I'll change the default setting.

Thanks again and please keep reporting bug / suggestion / feedback :)

Sounds like a good mod to me. Will check it out now. As to the delay, how hard would it be to scale it according to timewarp, so that it would be checked every, say, 1 game-minute (every 6 seconds under 10x, 0.6 seconds under 100x etc.)? It should also probably be switched off completely under very high timewarp (10000+), because it would make no sense when time of day changes almost every tick.

Share this post


Link to post
Share on other sites
6 hours ago, WuphonsReach said:

Can the dusk/dawn light toggle be slightly randomized, so that not all the lights turn on at the exact same time?

Not sure what you mean exactly, should all vessel's lights be toggled at the same time after a random delay when the sun goes down ? Or do you mean each individual light should be toggle one after another with a random delay between them ?

I like the first, not sure about the second, I'll try, see how it looks.

 

42 minutes ago, garwel said:

Sounds like a good mod to me. Will check it out now. As to the delay, how hard would it be to scale it according to timewarp, so that it would be checked every, say, 1 game-minute (every 6 seconds under 10x, 0.6 seconds under 100x etc.)? It should also probably be switched off completely under very high timewarp (10000+), because it would make no sense when time of day changes almost every tick.

On my last build, not released yet, I use a 1.5s delay between Raycast when time-warp is less than x5 and a 0.1s delay after that. I don't disable it when time-warping at more than 10000 but it's a good idea.

 

Thanks for the feedback :)

Share this post


Link to post
Share on other sites

Just an idea that if you have 20-30 lights in the scene, that maybe they should toggle in a staggered fashion over a period of a few minutes instead of 20-30 lights toggling at the exact same instant.  Not sure if it's feasible to do or not.

Share this post


Link to post
Share on other sites
20 minutes ago, WuphonsReach said:

Just an idea that if you have 20-30 lights in the scene, that maybe they should toggle in a staggered fashion over a period of a few minutes instead of 20-30 lights toggling at the exact same instant.  Not sure if it's feasible to do or not.

It is possible, I think a period of few minutes is too much tho, a few seconds between each light will be better.

Share this post


Link to post
Share on other sites
21 hours ago, Li0n said:

I'm worried about performance so I check for the sun position every 1.5s

From what I know the suncatcher of the solar panels is very robust in this field. I don't know the code, but solar panels always know when sunlight is available, and they do it at superwarp speeds.

Edited by Enceos

Share this post


Link to post
Share on other sites
22 minutes ago, Enceos said:

From what I know the suncatcher of the solar panels is very robust in this field. I don't know the code, but solar panels always know when sunlight is available, and they do it at superwarp speeds.

True that. I think solar panel rely on Vessel.sunLight (return true if the sun is up). I don't use it because it doesn't take into account the terrain, so I wrote my own raycast which cast on the layer I wanted to (scaled and Local Scenery).

Anyway there is no point to check for the sun at a high rate while on low time-wrap, in the next update I'll add somethings similar to what @garwel said here :

8 hours ago, garwel said:

Sounds like a good mod to me. Will check it out now. As to the delay, how hard would it be to scale it according to timewarp, so that it would be checked every, say, 1 game-minute (every 6 seconds under 10x, 0.6 seconds under 100x etc.)? It should also probably be switched off completely under very high timewarp (10000+), because it would make no sense when time of day changes almost every tick.

 

Edited by Li0n

Share this post


Link to post
Share on other sites

Version 1.1 is up ! On SpaceDock and Github

Quote

* Adjust the delay between two check of the sun position according to the warp-time speed
  * Settings.cfg : delay_in_low_timewarp (value get divided by the current time-warp speed) and delay_in_high_timewarp
* Change the default settings for the morse code, light will stay on longer
* Toggling a vessel light on EVA will no longer toggle its symmetry counter parts
  * Can be changed in the settings
  * Also add a setting to disable light interaction on EVA
* Add a setting to disable lightning of a part when a crew is inside, if used crewed part 's light will be toggled as the sun rises / fall
* Enhance settings behavior, adding new settings no longer force the whole settings.cfg file to be reset

For the issue about light action group being reset when reloading a craft in the VAB, noted by @Kottabos in his review, I couldn't reproduce it. If someone can, please share how.

 

I'll try to randomize the lightning a bit in the next release as suggested earlier.

Have fun :wink:

 

PS : I have forgot to mention it : the light that respond to the position of the sun are also toggled when reaching a certain depth (20m by default). I've made that in anticipation of the future awesomeness of KSP's undersea-world, that's a long shot I know...

Edited by Li0n

Share this post


Link to post
Share on other sites

Ten out of Ten! And throwing in a vote for WuphonsReachs idea of staggered lighting. I think them coming on in a staggered fashion as different systems trigger slightly out of sync with each other would just look so authentic as the automated lighting in our building here at work does just that. The outer building lights come on, then the entrance, then the parking lot and finally the rear of the building over the course of about five minutes. Now, I like the idea of a few seconds as in a game reality would be tedious. Maybe some type of extended grouping by function or type?

Oh, by the way, on CKAN where I saw this mod pop up the homepage link just goes to the forum landing page, and not to this page. Thankfully the name was so perfect for this mod I just knew it would be worth the search!

It's the little things like this that really add to the game. Thank you.

Share this post


Link to post
Share on other sites
4 hours ago, pslytely psycho said:

Ten out of Ten! And throwing in a vote for WuphonsReachs idea of staggered lighting. I think them coming on in a staggered fashion as different systems trigger slightly out of sync with each other would just look so authentic as the automated lighting in our building here at work does just that. The outer building lights come on, then the entrance, then the parking lot and finally the rear of the building over the course of about five minutes. Now, I like the idea of a few seconds as in a game reality would be tedious. Maybe some type of extended grouping by function or type?

Oh, by the way, on CKAN where I saw this mod pop up the homepage link just goes to the forum landing page, and not to this page. Thankfully the name was so perfect for this mod I just knew it would be worth the search!

It's the little things like this that really add to the game. Thank you.

Thanks.

I haven't got to the randomize lightning yet, I'm struggle on something else I would like to finish first, but it will be there, soontm :wink: 

For CKAN you right, I messed up my netkan metadata. I'll reach CKAN people, see how they can update it.

Share this post


Link to post
Share on other sites

Version 1.2 is up ! On SpaceDock and Github

Quote

* Light triggered by the sun are now lighted in a staggered way, can be disabled/tweaked in settings.cfg
* Some quality of life improvement of the code

@WuphonsReach thanks for the idea of the staggered light :)

At a time wrap of 10 000x or more it won't work very good (not much I can do about that) but the light should go to their correct state when time slow down.

Please report any issues or suggestions and enjoy :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.