Toddler's Forum Posts

  • With that sample javascript file, I tried Browser Log:

    JS.JSCodeValue("global_variable")

    and I got:

    ValerypopoffJS plugin: Error in 'JSCodeValue' expression

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

    JS code: global_variable

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

    global_variable is not defined

    Then I tried Browser Log:

    JS.Value("global_variable")

    And there is no error...instead...I got....0 !

  • It doesn't work:

    Sample Javascript file:

    var global_variable = "Global Variable's value.";

    function global_variable_function()

    {

    console.log("global variable function called");

    }

    var global_object = new class_object();

    class class_object

    {

    constructor()

    {

    this.name = "Kenny";

    this.age = 23;

    }

    internal_class_function()

    {

    console.log("Internal class function called.");

    }

    }

  • Thank you for your respond valerypopoff .

    I will be re-writing my educational notes to incorporate your plugin so any changes at this point is actually detrimental to my current momentum.

    However since you are open to request, may I request this:

    JS.VariableValue()

    With this, one will be able to JS.VariableValue("top_level_variable") to retrieve "Hello, I am top level variable".

    one will also be able to JS.VariableValue("newCharacter.age") to retrieve 23.

    This is straight forward, direct and just plain makes sense.

    ========================================================================

    Example *.js File:

    var top_level_variable = "Hello, I am top level variable".

    var newCharacter = new main_character();

    class main_character

    {

    constructor()

    {

    this.name = "Kenny";

    this.age = "23";

    this.number_of_death = 45;

    }

    some_internal_function_whatever_doesnt_matter()

    {

    }

    }

    ========================================================================

    without this method, currently users have to:

    Step 1: update your *.js file to include this: var _window = window;

    Step 2: Right after "All scripts loaded" is triggered, put in JS action "Init alias", set top textbox to "Global" and bottom textbox to "_window".

    Step 3: Now you can FINALLY access your global variables via: JS.AliasValue("Global.top_level_variable").

    Accessing Object's value is the same: JS.AliasValue("Global.newCharacter.age")

    You see how this one new feature will run circles around the current "alias" nonsense ?

  • Hi valerypopoff,

    I see your view, I also notice you often execute the quote "You are doing it wrong" followed by put down speeches questioning the capability of the questioner when you were simply nicely asked a question.

    Not asking you to remove your love of using alias, just asking for a rather consistent outlet, you did not ask for functions to be alias didn't you ? And yet it is possible to have functions within functions in JavaScript, you knew how silly it will be if you were to implement alias to functions, but you insist on not having a non alias way of accessing variable data.

    I can understand that you are thinking your script will only hold objects and functions and some kind of a punishment is given [via your silly alias nonsense] if one decides to have top level variables in the js files, but can you imagine how ridiculous it is to explicitly declare all top level variables in Construct 2 though?

    You will have variables not used by anything in Construct 2 whose sole existence is to have the objects and functions in the js files interact with it, it is much preferable to have these variables tucked clean and neat inside the js file itself.

    It's ok, I see no resolution to this the same way I see that you are utterly insistent on "All scripts loaded" being by default a continuous trigger [which makes no sense to anyone besides you] and yet knowing that by your own logic, construct 2's internal "On loader layout complete" would be a continuous loop which of course, would be utterly retarded if it was so.

    I think you are doing some mental gymnastic compartmentalization here.

    However, it is a fact that despite these two flaws [yes yes I am doing it wrong because you are right I got it] your plugin is truly powerful.

    So I will use it as it is and appreciate the gift you have given the Construct 2 community :D

    Thank you valerypopoff .

    I really do wish you well because me and my students is going to benefit from this amazing work of yours.

  • Thank you so much valerypopoff !

    This is a truly powerful plugin.

    I have updated the core docs for my students and will be updating the curriculum to include this plugin of yours.

    Your resulting work is a very very powerful plugin and is going to change a lot of my C2 lessons to come as the complexity of projects can now include heavy duty object orientated programming concepts, these are the core Docs for your plugin to be included in my notes, hope it will help others here, I apologize that it can be a little too straight forward but as a teacher I know what my students will ask and be confused about so I rather lay it out in the notes:

    This is a powerful plugin that allows full utilization of JavaScript in Construct 2 !

    Step 1: Place plugin into your project & rename it to "JS" for convenience.

    Step 2: Import file *.js files (as many as you like) into construct 2's "Files" folder.

    Step 3: Select JS plugin & enter the file name(s) e.g. "src1.js;src2.js" into the script files section.

    Now you can start to use it !

    Only start using it when "All scripts loaded" is triggered.

    For some stubborn reason, the creator choose to make it so that this event triggers continuously.

    His reason is "because all scripts are indeed loaded and hence will always be true, always triggering."

    That would be like saying the "On loader layout complete" event is indeed completed and hence will always be triggering, common sense will tell you such events should only trigger once.

    Because of this pure stubbornness on the creator's side, please add in the "Trigger once" event to the "All scripts loaded" event so that it finally makes sense.

    Accessing Global or Object Function (with or without return data):

    Under Action, choose "Call JS function (stores return value)", enter function name inside example "function_name", for object just do "object1.function_name".

    Return values is contained in: JS.StoredReturnValue.

    Accessing Global or Object Variable:

    This is another point of stubbornness from the creator, you have to create some silly "alias" nonsense that will be treated as the variable and access it using the alias.

    Instead of allowing direct access just like the way functions are accessed [see top, notice you don't require an alias to access a function which actually makes sense],

    the creator's stubbornness insist on the alias nonsense, his round about solution to this nonsense is:

    Step 1: update your *.js file to include this: var _window = window;

    Step 2: Right after "All scripts loaded" is triggered, put in JS action "Init alias", set top textbox to "Global" and bottom textbox to "_window".

    Step 3: Now you can FINALLY access your global variables via: JS.AliasValue("Global.global_variable"). //Global.whatever_global_variable_name_you_choose.

    Accessing Object's value is the same: JS.AliasValue("Global.object1.name")

    Creating your own trigger:

    This is single handedly the most powerful feature of the plugin.

    To be honest, it doesn't "actually" create a custom trigger but merely calls a function set within Construct 2,

    but this is enough, it is all your need for back and forth communication and triggering.

    First, implement the following code into your *.js file:

    function execute_construct_function(function_name, args)

    {

    if (function_name == "")

    {

    return;

    }

    args = (args === undefined) ? [] : args;

    if ( c2_callFunction !== undefined )

    {

    return c2_callFunction(function_name, args);

    }

    }

    Now all you have to do in your JavaScript is call:

    execute_construct_function("Trigger"); //Assuming you have a Construct 2 function called "Trigger"

    and it will work ! AMAZING ! This officially make this plugin the most powerful and flexible plugin in all of Construct 2's plugin history !

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Usage:

    Select the JS plugin, inside the script files section, enter the script files, example: script1.js;script2.js

    Import all the *.js files into the "Files" folder.

    Call JS function:

    Allows you to call a function from the js file.

    You can even call object functions like this: object1.function1.

    Return value can be accessed via JS.StoredReturnValue.

    Since StoredReturnValue contains only string, use JSON to transfer your data.

    To access a variable from a javascript file, you have to "Init alias" to set an alias for the variable.

    and then you can: js.AliasValue("enter the alias name here").

    Can we skip this step and straight away access the variable directly ?

    Like instead of js.AliasValue("enter the alias name here")

    we can just have js.variable_value("enter variable name here").

    So all in all I have three questions summarized:

    Question 1: Why is "All scripts loaded" continuously triggering ?

    It should trigger once when all the script is loaded and never trigger again ever.

    You don't see construct 2's On loader layout complete continuously triggering, it trigger once and stop.

    Question 2: Can we have js.variable_value("enter variable name here") instead of js.AliasValue("enter the alias name here") ?

    It's more direct, the alias just adds unnecessary levels of convolution.

    Question 3: Now this is difficult I think...can you somehow create a way for the custom javascript to have its own triggers ?

  • Hi valerypopoff

    I analyzed your example *.js file to try and figure out why you didn't use class and I saw this:

    var Enemy = Object.assign( {}, Player );

    This is where I immediately understood why you didn't choose to do so.

    If Player were an instance of a class, instead of typing that simple line, we will be looking at:

    var Enemy = Object.assign( Object.create( Object.getPrototypeOf (Player) ) , Player);

    Which is a little less elegant I suppose.

    Is that your reason ?

  • Hi valerypopoff I am currently reading up on your site [VERY WELL DONE by the way, the amount of visual design work you put into explaining this plugin is...b.e.a.u.t.i.f.u.l. You are truly a designer at heart].

    I am seeing:

    var player =

    {

    bla bla bla

    }

    You...you are not using class ?

    Can I use class ? I really want to use class...it's more OOP like.

    Is that possible ?

  • Hi valerypopoff,

    Interesting Add-on, could be useful.

  • youtube.com/watch

    Created using Construct 2, had lots of fun making it :D

  • Anyone ?

  • Just wanted to see if I can form a small friend group whom we can talk about game programming or whatnot using Construct 2.

    Not more than 5.

    I don't even know if there would be 2.

  • Exported to windows.

    Open Visual Studio 2015->Create Package->THIS:

    App manifest references the image 'images\Logo.png' which does not have a candidate in main app package.

    App manifest references the image 'images\storelogo.png' which does not have a candidate in main app package.

    App manifest references the image 'images\splashscreen.png' which does not have a candidate in main app package.

    If you are not going to fix this, can you atleast warn us about the size of those images so that we can do it IN THE MIST of exporting from Visual Studio ?

  • Just released my app after 2 days of NIGHTMARE with your badly configured package.appxmanifest file and config.xml.

    ==============================

    iOS Nightmare:

    How to generate pfx for phonegap which is needed for windows 10 universal app ?

    Seriously man, now that Intel XDK has died, the "taste" of creating apps using construct two is dying for me.

    Finally managed to get Phone gap to build for iOS and Android BUT the BOTH requires one to edit the "config.xml", because the config file that Construct 2 build does not generate three specific icon sizes that one have to create and THEN edit the config.xml to show it.

    And also the number of version decimal points is different for iOS so even if Phonegap build construct 2 file for iOS correctly, it will fail on application upload and one have to re-edit the config file to match Apple's version number decimal point expectation and re-generate again in Phone gap.

    What an unnecessary nightmare you have created for us your users because you are too lazy to properly format construct 2's config.xml file....

    ==============================

    ==============================

    Android Nightmare:

    Phone gap by default ONLY generate the x86 version for Construct 2's build, you have to edit the config.xml to FORCE it to generate for ARM which is where most of the device is at.

    What an unnecessary nightmare you have created for us your users because you are too lazy to properly format construct 2's config.xml file....

    ==============================

    ===============================

    Windows Nightmare:

    Building the output from Construct 2 for Windows app is a FXXXXXX Nightmare !

    Your package.appxmanifest file is COMPLETELY OFF the chart, needed icons that are not there, manually assigned icons to it using visual studio's designer interface (to reduce error from manually editing the appzmanifest file) only to hit a ton of bricks of errors from visual studio and finally some of the meta data inside that were not suppose to be there are being complained by Visual Studio about your package.appxmanifest file.

    ===============================

    I have managed to get the apps out but seriously this is an uncalled for nightmare, without XDK spoon feeding Construct 2, its failings are showing.

    Dear Construct 2, can you please format your config file PROPERLY, if you are going to do such a bad job generating your config file and your package.appxmanifest file, you might as well don't do anything.

    Intel XDK is dead, if you don't buck up, nobody will use your program BECAUSE it cannot output to ANYTHING without a ton of problems !

    You know what else ? To generate for windows 10, phone gap requires pfx file too, and that is a WHOLE TON OF BRICKS man, not like anybody cares about the windows 10 app store but seriously, exporting using construct 2 is becoming more trouble then it is Fxxxxxx worth at this point, if the situation don't improve I am switching.

  • Intel XDK is Dead, now what ?

    Tried to follow this tutorial:

    Subscribe to Construct videos now

    But then at 10 minutes, he opened open Intel XDK to use its build capabilities, that method assumes cert are PRE-generated as new android cert can no longer be generated as the service is now cut, importing cert is also now impossible.

    So...now what ?

    Phone gap requires a subscription, not a per month payment, and I heard to cancel an adobe subscription is hell, so now what ?