Someone figured out how to add Lua scripting support to an NES emulator. The Lua interpreter acts like a second CPU on the NES bus, with the ability to read and write the NES's RAM and draw to a layer in front of the emulated screen. People have used this to make Super Mario: Canvas Curse, and they have used it to make Tetris for NES into a netplay game.
It's really more like a detoothed debugger/overlay system; outside of reading/writing RAM, you really can't do much.