OnTriggerStay is called once per frame just as Update is. Using OnTriggerEnter and OnTriggerExit, you can achieve what you describe via a boolean flag:
var inside : boolean = false;
function OnTriggerEnter() {
inside = true;
}
function OnTriggerExit() {
inside = false;
}
function Update() {
if(inside) DoX();
else DoY();
}
it is not enough, not always, for exemple, in some circunstancy you miss the moment of “OnTriggerExit” for some complex reason such as parenting, the “stay” will be still confirmed. Actually if there is not the reverse effect, there is no reason for “OnTriggerStay”, it would be the same thing of OnTriggerEnter