I am porting a global plugin I made awhile ago over to v2.
In my original plugin the calls to GetCurrentEventStackFrame and GetCurrentEvent worked fine.
Once I upgraded to V2 I get this.runtime.GetCurrentEventStackFrame is not a function
Any guidance would be appreciated
Here is the original condition:
"use strict";
{
self.C3.Plugins.RGBZ_PubSub.Cnds =
{
SubscribeToEvent(name)
{
console.info(`Subscribe called ${name}`);
const current_frame = this._runtime.GetCurrentEventStackFrame();
const current_event = this._runtime.GetCurrentEvent();
const eventId = current_event._sid.toString() + '-' + current_frame._cndIndex.toString();
if (this.EventPublished && this.EventPublished.Name==name.toLowerCase()
&& this.EventPublished.HandledBy.find(x=>x==eventId)==null) {
this.EventPublished.HandledBy.push(eventId);
return true;
}
else {
return false;
}
}
};
}
Here is the new V2 version
"use strict";
const C3 = globalThis.C3;
C3.Plugins.RGBZ_PubSub.Cnds =
{
SubscribeToEvent(name)
{
console.info(`Subscribe called ${name}`);
const current_frame = this.runtime.GetCurrentEventStackFrame();
const current_event = this.runtime.GetCurrentEvent();
const eventId = current_event._sid.toString() + '-' + current_frame._cndIndex.toString();
if (this.EventPublished && this.EventPublished.Name==name.toLowerCase()
&& this.EventPublished.HandledBy.find(x=>x==eventId)==null) {
this.EventPublished.HandledBy.push(eventId);
return true;
}
else {
return false;
}
}
};