Garry's Mod

Garry's Mod

129 ratings
Auto-Flashlight
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Effects
Addon Tags: Roleplay, Scenic
File Size
Posted
Updated
6.424 KB
18 Sep, 2023 @ 8:02pm
21 Sep, 2023 @ 1:13pm
2 Change Notes ( view )

Subscribe to download
Auto-Flashlight

Description
Auto-flashlight will automatically switch your flashlight on when you are in dark areas, and will switch it off when in brighter areas.

Settings are available in the spawnmenu under Options -> Auto-Flashlight -> Settings.

However, if you prefer to use console variables:

  • cl_flashlight_auto (0/1): Whether or not auto-flashlight is enabled.
  • cl_flashlight_auto_threshold (0 .. 0.5): The threshold for the automatic flashlight to trigger. Higher values mean the flashlight will activate in brighter areas.
  • cl_flashlight_auto_frequency (0.05 .. 2): How often Auto-Flashlight should check to see if the player is in darkness.

Should work just fine with addons such as Third-Person Flashlight.

Comes with a basic developer API if developers want to change the functionality of how it works.

Flashlight icon credit: https://www.iconfinder.com/icons/10948174/
14 Comments
ph0roggy 25 Jan @ 10:58am 
what the guy said below, that would be genius
PÖIЙ† βLΛЙK 3 May, 2024 @ 8:26pm 
Someone should add a setting where the flashlight is perpetually on, but the brightness fades in and out based on current light levels
HX 3 Nov, 2023 @ 2:08pm 
epic mod
:steamthumbsup:
Sr. Prime 23 Sep, 2023 @ 11:56am 
perfect!
Yavuzhan 22 Sep, 2023 @ 11:28am 
Yeah this is really sweet, good job!
ATP-1002 22 Sep, 2023 @ 3:01am 
This is some high-level coding where the game knows what to do when Y is near or around X with needing a map script.
Fantastic job!
Lombaxtard 21 Sep, 2023 @ 1:16pm 
That should be enough
Thanks a lot for that :steamthumbsup:
Chev  [author] 21 Sep, 2023 @ 1:15pm 
I added the ability to change the frequency of the check. The minimum value is 0.05 seconds and maximum is 2 seconds.
Lombaxtard 21 Sep, 2023 @ 12:22pm 
If you can, please
Even this simple check can add up and impact frames heavily, especially on a crappy cpu such as mine
Chev  [author] 21 Sep, 2023 @ 12:21pm 
Right now it runs every 0.1 seconds. The script is fairly lightweight so it shouldn't have a big performance impact. The main annoyance I've noticed so far is if you're going through light and dark areas really fast, the flashlight will flicker on and off. I could probably add a setting to adjust the timer frequency.