Triggering email notifications with luup code


I have the luup code pulled from a thread for email notifications. My question is, how do I associate it with an event, like when my lamp switch turns on?


not in front of my box at the moment- but basically you create a scene with the lamp turning on as the trigger. Then you paste the luup code in the luup tab of the scene. (you have to paste the luup code then save it then save the actual scene).

when the trigger occurs the luup code will run.

Is there a way of making so that the code is reused, rather than pasting the same code to each scene?

Maybe triggering a global function where i can pass arguments to change the messaging?