valerypopoff's Recent Forum Activity

  • When importing C2 projects, C3 guesses the C3 ID by converting to lowercase and adding dashes, e.g. "My Property" -> "my-property". You used an underscore though ("my_property"), if you use a dash it should import correctly. If it doesn't automatically get the right name you can use the LoadC2Property method. But I just realised none of this is documented, so I should update the docs

    Now LoadC2Property is documented here

    construct.net/make-games/manuals/addon-sdk/reference/base-classes/iinstancebase

    But it's still unclear how to use this method. There's "Script files" property in the c2 version of my plugin. And there's a corresponding "Scriptfiles" property ID in the c3 version. How do I override this using LoadC2Property method?

  • Hey guys! I'm on Patreon now. So if you ever wanted to support me, this is about time:

    Support me on Patreon

  • You can't convert a plugin with Code Templater. You can only create (or recreate) a plugin from scratch with it. Sometimes it makes sense and pays off though. If you got a plugin on your hands that is only for C2, you can recreate it in Code Templater and get all three versions: C2, C3 and C3 runtime 3

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Is a port from the plugin to the new C3-Runtime possible ? :)

    The new version wit C3-Runtime support is out!

    construct.net/make-games/addons/1/javascript

  • Hey!

    JS.AliasValue is a Construct expression. It only returns Construct basic types: number or string. It can't return arrays. Construct doesn't understand this type of variables.

    Thus, JS.AliasValue( "wavePoints" ) returns 0, so you're calling function "updateWavePoints" with parameter "0".

    Also the thing that you're doing is very strange. You have both "updateWavePoints" function and "wavePoints" array in javascript, but instead of calling the function in javascript code, you're trying to call it from Construct. That is wrong on so many levels.

    If you're using Javascript Plugin you're supposed to either call javascript functions with parameters from Construct, or do Construct stuff using data from javascript. Using plugin to call javascript functions that operate on javascript data that was taken from javascript to Construst and translated back to javascript, — is weird and ineffective.

    Hi, i've a problem with arrays. I've two functions in my js, the first one return an array as result, and it works correctly. Then i need to call the second one passing the array (stored in an alias) as parameter but it seems to not working. What i'm wrong!?

    As you can see, "wavePoints" is an array, and i would like to pass to "updateWavePoints" function.

  • It's hard to create and maintain several versions of the plugin for several Construct versions. The actual code is all the same, but you need to wrap it into different file structures, classes and manifests for each Construct version. This is a boring work that can be automated. This is when Code Templater comes in useful.

    Generate plugins with "Code Templater"

    Code Templater is a tool that enables you to describe a Construct plugin in a special format just once and get the code of Construct2, Construct 3 and even Construct 3 (c3 runtime) plugins all at once generated in a click of a button.

    You can later easily maintain the plugin quickly updating it without the need to go through versions, files, folders and xml's.

    Read about how Code Templater works on its promo page: Code Templater promo

    These plugins are created with Code Templater

    The gist

    1. Describe the plugin (sample comes in example files)

    2. Describe ACEs (sample comes in example files)

    3. Provide Construct plugin template (comes in example files)

    4. Get all plugin versions generated in one click

  • 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;.

  • 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.

  • 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'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.

  • What's the situation with this.runtime.getProjectFileUrl in the new C3 runtime? How do I get file urls?

    Ashley

    Due to the way preview mode works in C3 loading local files has to be done slightly differently. This is one of the few differences in the runtime in C3. Instead of using "myscript.js" directly, call:

    var realUrl = this.runtime.getProjectFileUrl("myscript.js");[/code:26wp3i4q]
    
    That gives you the real URL to request that will work in both preview and export.
  • There's access to the runtime from global javascript scope. You can access it using my plugin or just using Construct Browser plugin.

    How to access canvas div via cr object — has nothing to do with the way you invoke javascript. Can't help you with that, sorry.

    Is there any access to the runtime - canvas div with your plugin and with a own javascript-call? valerypopoff

    > 	function test() {
    		console.log(typeof cr.runtime.canvasdiv); // get undefined
    	}
    
valerypopoff's avatar

valerypopoff

Early Adopter

Member since 7 Aug, 2016

Twitter
valerypopoff has 34 followers

Connect with valerypopoff

Trophy Case

  • 8-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

10/44
How to earn trophies