[Plugin] JavaScript (C2 and C3)

2 favourites
From the Asset Store
A cool way for kids to write and practice English Alphabets
  • Javascript Plugin v.0.7.0 is out!

    +C3 runtime support

    Use 3rd party js libraries (including JQuery), call javascript functions, access object properties and methods. Implement game objects, and algorithms in javascript.

    This plugin also enables you to organize the model and algorithmic parts of your game in javascript. Organize objects, classes, functions and arrays in a javascript file. Do loops, algorithms and other stuff – which Construct event sheets are not designed for – in a javascript. Only pass algorithm results and object values to Construct when needed.

    Include js script into your project and access objects, variables and functions from anywhere in a game.

    More about the plugin, downloads and examples — on plugin's promo page

  • newt Phacanu totoe irina

    The Construct 2 plugin version is released. See the top post to get the download link.

    In Construct 2 version conditions "Compare Function's Return value" and "Compare JS code Completion value" have reversed parameters order. I had to do that due to the differences between how Construct 2 and Construct 3 work.

    So instead of this:

    You'll have this:

  • Beautiful.

    Thank you sir.

  • valerypopoff O man this looks amazing, I'm guessing that the file structure has to stay the same?And it automatically just includes all files instead of just one?

  • Great news, some powerfull stuff you got there!!!

    cheers!

  • Not sure if I now what you mean. The file structure of what?

    If you mean the file structure of included javascript, then yes. You can include any valid script. Any valid scriptS, actually.

    Just put them into the "Script files" field like this:

    script1.js;script2.js (Only for Construct 2. In Construct 3 you put every script in a separate line)

    There's no multiline text fields in Construct 2 plugin properties, so you have to separate scripts with ;

    After the scripts are loaded, they are executed the same way it works when you add scripts to any webpage.

    valerypopoff O man this looks amazing, I'm guessing that the file structure has to stay the same?And it automatically just includes all files instead of just one?

  • Yea, that's what I meant, thanks! valerypopoff

  • Can you explain why the StoredReturnValue don't work?

    I test alot of JS codes, even simple ones and don't return any value, even if i specified.

    Example:

    "
    
    function myFunction(#0,#1) {
    return #0+#1;
    }
    
    "[/code:2drr3d1i]
    
    Its just two Global Variables in construct to sum and return the result.
    As you said the only value who return its "0".
  • I may be wrong but it really looks like you're not so good at javascript. If so, I would suggest you not to use this plugin. Can't think of a single scenario how you can benefit from using it if you don't know how to properly use javascript.

    Now I'm gonna explain why it doesn't work as you expected. But I strongly recommend you to read about javascript functions.

    It's not obvious from what you said but I'm guessing you're using Execute JS code action. If so and the Code parameter is

    "
    
    function myFunction(#0,#1) {
    return #0+#1;
    }
    
    "[/code:1z4qpjwb]
    it will return [b]undefined[/b]. StoredReturnValue works. It just returns [b]undefined[/b]. And in Construct you see it as 0.
    
    The reason it returns undefined is that in your code you only define the function and never call it. A function definition doesn't return anything. Truth to be told this is not even a proper definition you've got there. The action will simply substitute #0 and #1 with the values of the parameters you pass. So the code you're trying to execute is something like:
    [code:1z4qpjwb]"
    
    function myFunction(7,12) {
    return 7+12;
    }
    
    "[/code:1z4qpjwb]
    and if you preview the project and look in the console (always look in the console) you'll see that you're getting a syntax error which in this case is "Unexpected number". Because you can't put numbers in parenthesis in a function definition. It must be names of parameters.
    
    So what you should have done is to define a function first and then call it:
    [code:1z4qpjwb]"
    
    function myFunction(a, b) {
    return a+b;
    }
    
    myFunction(#0,#1);
    
    "[/code:1z4qpjwb]
    
    
    

    Can you explain why the StoredReturnValue don't work?

    I test alot of JS codes, even simple ones and don't return any value, even if i specified.

    Example:

    "
    
    function myFunction(#0,#1) {
    return #0+#1;
    }
    
    "[/code:1z4qpjwb]
    
    Its just two Global Variables in construct to sum and return the result.
    As you said the only value who return its "0".
    
  • Oh! Thanks for the explanation! Sorry for bothering you.

    Now i got it.

    Kinda new in Javascript.... Cheers for you plugin.

    Have a nice day!

  • Thanks for this useful plugin

  • CS2 Plugin version is down dude.

  • CS2 Plugin version is down dude.

    Freaking dropbox! Fixed it, thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The new version of a plugin is out! Check it on plugin's promo page:

    https://readymag.com/valerypopoff/valer ... js-plugin/

    What's new:

    — Aliases: an easy mechanism to work with js-objects, its properties and methods

    — Plugin is now "Single global" which means you can only have one instance of a plugin in a project

    — Everything works faster because functions and aliases aren't implemented with eval( ) anymore

  • This is awesome! Exactly what I was looking for. Ill definitely be using this

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