C3 runtime SDK documentation now available

  • The C3 runtime SDK download for plugins and behaviors is now available. The addon downloads now include C3 runtime ports to demonstrate how they work. Find the downloads here: https://www.construct.net/make-games/manuals/addon-sdk

    (Note the effects SDK has no changes; it's 100% compatible with the C3 runtime already, because it doesn't involve any JavaScript code.)

    The initial version of the C3 runtime API documentation is available here: https://www.construct.net/make-games/manuals/addon-sdk/runtime-reference

    The runtime has a very large API surface. The documentation does not yet cover everything, but it should be a good start.

    For more information on how to make an addon for the C3 runtime, please see the new section on Runtime scripts in the guide. This is not yet 100% complete - it still needs to cover how to access DOM features when hosted in a worker, but there's no way to test that yet, so it's not covered for the time being. Please also note the section about use of private or undocumented API calls; you should not use these, we won't provide support for them, and we can't guarantee they will be kept backwards-compatible.

    Hopefully this is enough to allow addon developers to start porting to the new C3 runtime. If you have any questions about the new C3 runtime SDK, or need any particular areas that aren't covered at all to be documented, please let me know!

  • I'm about to migrate my plugin to the C3 runtime.

    Now expression methods should return the value using "return" statement instead of calling ret.set_int/set_float/set_string like it was in the C2 runtime. It's cool and all but I need to support both (C2 runtime and C3 runtime) versions of the plugin and the last thing I need is having two of every expression methods that are almost identical.

    I thought I could avoid having identical methods by doing both "return" and "ret_set":

    Expression() 
    { 
    	// code goes here ------------
    
    	ret.set_any( result ); 
    	return result;
    }
    
    

    But it doesn't work because when running in C2 runtime Construct says Assertion failure: Plugin mistake: Don't return values from the expression method - call ret.set_int/set_float/set_string instead

    Is it really that necessary to not let me use "return" statement in expression methods? It would be so much more convenient if I could.

  • It won't work in the C3 runtime either, because ret is not defined. So, sorry, that won't work at all.

    It's a trivial change - we've done it for all the official addons and I don't think it's really a big part of porting an addon.

  • Well it does work because it's actually:

    Expression()
    {
    	//- C2-C3 COMPATIBILITY ------------------------
    	var params_ = Array.from(arguments);
    	var ret;
    	
    	if( __CONSTRUCT3_RUNTIME3__ )
    		ret = {set_int(){}, set_float(){}, set_string(){}, set_any(){}};
    	else
    	{
    		ret = params_[0];
    	
    		for( var i=0; i<params_.length-1; i++ ) 
    		params_[i] = params_[i+1];
    	
    		params_.pop();
    	}
    	//----------------------------------------------
    
    	// runtime-independent code goes here ----------
    
    	ret.set_any( result );
    	return result;
    }
    

    The question is why does the engine throw this error when it's actually a mere warning that doesn't break the game, the engine, and doesn't even show when you export the game (it only shows in preview mode).

    It's easy to say that it's a trivial change when it comes to someone else's code. It hurts that I can't come up with the workaround that's convenient to me just because of the error that's not even a real error.

    It won't work in the C3 runtime either, because ret is not defined. So, sorry, that won't work at all.

    It's a trivial change - we've done it for all the official addons and I don't think it's really a big part of porting an addon.

  • I ended up doing this and it works fine:

    if( __CONSTRUCT3_RUNTIME3__ )
    return result;
    else
    ret.set_any( result ); 
    

    But still...

    It won't work in the C3 runtime either, because ret is not defined. So, sorry, that won't work at all.

    It's a trivial change - we've done it for all the official addons and I don't think it's really a big part of porting an addon.

  • The C2 runtime throws that warning to catch accidental use of return value; instead of ret.set_float(value);. All that compatibility code will also have a high performance overhead. You have to change the rest of the addon anyway, including the way the expression methods are declared - since you have to do all of that, I don't think it's a big change to replace ret.set_float(value) with return value;.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, I hear you. Cheers!

    The C2 runtime throws that warning to catch accidental use of return value; instead of ret.set_float(value);. All that compatibility code will also have a high performance overhead. You have to change the rest of the addon anyway, including the way the expression methods are declared - since you have to do all of that, I don't think it's a big change to replace ret.set_float(value) with return value;.

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