Run script on events?

Look at the ISY Event Handler addon. It triggers some home automation stuff when certain things happen. You could base what you need off that.

Otherwise, if you are writing a script, you can use xbmc.Monitor class to receive notifications when certain events happen: http://mirrors.xbmc.org/docs/python-docs/15.x-isengard/xbmc.html#Monitor

That is probably what the Event Handler uses.