You know, it has been
years
that I implemented Lua scripting in the Cool VL Viewer, with automation features (based on Lua callbacks for the various events happening in the viewer or in world), UI customizations (you can design your own Lua floaters if you want), Lua threading support (better than coroutines since they do not impact the viewer main thread as much as the latter), Lua and LSL interaction (and Lua and D-Bus interaction too, under Linux) etc...
Granted, my viewer is very different from LL's, but most of what I implemented for Lua could be backported to LL's code base (and all TPVs deriving from it).
The full documentation for my implementation is available here: http://sldev.free.fr/CoolVLViewerLuaManual.pdf