Maybe this thread can help.

The code from ventilator works great.

I made a small test level to test the script, you may find it here.

http://files.filefront.com/slopetest.zip/;8010117;/fileinfo.html

Hope this help.