How would I go about making a lens flare script?
well, at blender.org, there is a whole page on using halos to make lens flares. Check out the techniques there and try to make a good flare. Then try to retrace your steps using only python.
There’s an idea at how you might start.
http://wiki.blender.org/index.php/Doc:Manual/Materials/Halos
Sadly I can only use multitexture.