Programming With Bloom

Suppose I wanted to write a script to gradually make the bloom effect brighter and brighter (in other words, steadily decrease the “pp_bloom_darken” variable). What Lua code would I use to do that, and how would I run the script in-game?

You could do something like this:

[lua]local function ChangeBloom()
local bloom = GetConVarNumber(“pp_bloom_darken”)
if bloom >= 20 then
bloom = bloom - 1
bloom = bloom + 1

Basically, you set the bloom higher/lower however you want in a function, then make a continuously running timer with that function. The second argument, 2, makes it run every 2 seconds. You can change that however you want.

Ah, that looks perfect! Now, as an utter newbie, could you tell me how to run the script in-game?

In your garrysmod directory, there’s a folder called “lua”. Put this script in a lua file in your /lua/autorun/client, and do one of two things:

A. change the map
B. type this in console:
lua_openscript_cl autorun/client/<file name>.lua

Obviously, you replace <file name> with the name of your file.