SDK V2 GetCurrentEventStackFrame

0 favourites
  • 6 posts
From the Asset Store
Telegram Mini Apps SDK is a plugin that allows impliment Telegram Mini Apps features.
  • 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;
    		}
    	}
    };
    
  • I had put in a feature request for this.

    github.com/Scirra/Construct-feature-requests/issues/270

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • That feature request appears to reference supporting looping conditions, which is now supported with the createLoopingConditionContext() API. All the old APIs around the event sheet manager, current event etc. where previously only there in order to support looping conditions, which is now more conveniently handled with the new API.

    I'd rather not expose the internals of the event system, as it is a very large and complex API, exposing such details to addons can severely limit our ability to make future improvements, and I'd rather addons did not tinker with the event system anyway, as sometimes addon developers do things that contradict the intended design of the event system. We could consider small, specific features, if they have a clear and important use case that cannot be feasibly achieved any other way.

  • Thank you for getting back to me. You were right, as I looked at what my plugin was actually doing I really didn't need to call those event sheet functions. I was able to make it work correctly without those calls and now my plugin is all set for v2.

  • Is there a manual entry for : createLoopingConditionContext()

    I can't seem to find it.

  • Usually the manual is only updated at the next stable release in order to avoid documenting things that don't work in the latest stable release, and so possibly resulting in addon developers releasing addons that don't work for the majority of customers using the latest stable release. That method is currently only available in beta releases, but I did describe how it works in this forum post.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)