valerypopoff's Recent Forum Activity

  • Ashley Thanks! That's a good advice. Will try to avoid eval if it's possible.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This isn't a meaningful test. The JS engine can see that the executed JavaScript will have no effect at all, and just ignore it. However in practice nobody uses JavaScript that has no effect at all, so it's not important if this case is optimised or not. Different browsers will have different approaches.

    I checked. JS engine doesn't ignore this code and properly executes it. It's easy to check in a console. Just declare a variable that is later altered with the code we're talking about and see in console whether the variable was altered.

    And still 100x difference between Chrome and Safari. Can it be not the JS issue then? Maybe it has something to do with the plugin action call itself?

  • Ashley any ideas?

  • I was experimenting with executing javascript code from Construct 3 and noticed something rather strange. A simple JS code is executed 100 times slower than the simplest native Construct instruction. But only in Chrome. In Safari it's the same.

    Here's the example project: test.c3p

    Safari 11.0.2

    — 3,000,000 empty loops: 4.5 sec

    — 3,000,000 loops with "System: Set VARIABLE to 666": 8.9 sec

    — 3,000,000 loops with "Browser: Execute javascript 'var variable=666'": 8.5 sec

    Chrome 63.0.3239.132

    — 3,000,000 empty loops: 0.88 sec

    — 3,000,000 loops with "System: Set VARIABLE to 666": 1.2 sec

    — 30,000 loops with "Browser: Execute javascript 'var variable=666'": 1.65 sec

    See? I tested javascript execution in Chrome on 30,000 loops instead of 3,000,000 because otherwise it hangs the browser dead and seems to never execute it.

    Same thing when I use my own Javascript plugin that simply does "eval" of a string you pass to it. Is it normal or what?

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

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

  • 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

  • I guess in my case I can not.

    I made a plugin with the condition that works like this:

    It works perfectly in Construct 3 but this is a problem for Construct 2. What would you recommend?

    Variadic parameters were implemented solely for the Function plugin. Anything the Function plugin doesn't need may be missing or buggy. I'd advise against using them if you can.

  • Holy cow! Is this documented anywhere?

    valerypopoff I'm anxious to test your plugin.

    This error is probably because you put AddVariadicParams in the middle of the condition. In Construct 2 this operation can only be at the end.

    Cheers.

  • Problem Description

    When there's a plugin with a Condition with a parameter added with AddVariadicParams, an error pops up in Construct when editing condition parameters and clicking on "Add parameter" link. The error only pops up if Variadic parameter is not added the last. If it's the last parameter listed, everything is ok.

    When you click "Retry", the error pop up goes away and everything works. Even the condition works correctly. On runtime it sees all the Variadic parameters you pass.

    Attach a Capx

    Don't know what to attach since the problem is in a plugin mechanism

    Description of Capx

    Same here

    Steps to Reproduce Bug

    • Add to any plugin a Condition with AddVariadicParams("Name", "Description"); (which is not the last one)
    • Open Construct
    • Create a project
    • Create a condition
    • Click "Add parameter" link

    Observed Result

    Error pops up

    Expected Result

    Opens a new field for a parameter

    Affected Browsers

    • Chrome: (YES)

    Operating System and Service Pack

    Windows 10 Pro 64-bit

    Construct 2 Version ID

    248 (64-bit) checked

    Here's the content of the error pop up:

    ---------------------------

    Construct 2 Check failure

    ---------------------------

    Check failure! This is probably a bug:

    Calling GetScintilla() on non-scintilla control

    Condition: HasScintilla()

    File: Projects\Parameters.cpp

    Line: 3198

    Function: class CScintilla &__cdecl ParamControlSet::GetScintilla(int)

    Build: release 248 (64-bit) checked

    Component: Construct 2 IDE

    (Last Win32 error: 0)

    You are using a 'checked' release of Construct 2, intended for testing, which causes certain errors to be reported this way. Hit Ctrl+C to copy this messagebox - it's useful information for the developers, so please include it with any bug reports! Click 'Abort' to quit (unsaved data will be lost!),'Retry' to turn off messages for this session and continue, or 'Ignore' to continue normally.

    ---------------------------

    Abort Retry Ignore

    ---------------------------

  • Has the development of this plugin died out?

    I've updated it to version 1.0 which is good for Construct 3 and also frame rate independent. The plugin pretty much nails all my needs now and I don't really know what to improve. Any ideas?

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