EDIT: Most if not all of the links in that thread are broken because of a change in the forum software. I think they're all in the User Contributions forum, so just use my user name, pick a word from the Subject and use a range (within a 2-year period) from about 3-5 years ago (give or take a couple years depending on the thread).
I know you're using Lite-C, but click on "master list" in my signature and take a look at my light C-script. I wanted a comprehensive (or close to it) dynamic light script, so I threw in everything I thought I'd need (but I have a simple one too

). Anyway, maybe it will give you some idea if you can read my hack.
Here's a direct link:
http://www.coniserver.net/ubb7/ubbthreads.php?ubb=showflat&Number=41245