Javascript (Construct 2 Plugins)

  • 19
    This content is deleted
    Extension
    Javascript

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

You're viewing a single comment in a conversation. View all the comments
  • 6 Comments

  • Order by
  • I think I found a bug with the plugin. an alias with multiple variables overwrites if they are same. For example:

    var RectA = {

    left: 10,

    top: 10,

    right: 30,

    bottom: 30

    };

    var RectB = {

    left: 20,

    top: 20,

    right: 50,

    bottom: 50

    Setting alias RectA.left writes to both RectA and RectB. The only way to get around that is to use RectA.left1 RectB.left2

    • Ok, now I got this. This is not a bug. You're just using Aliases wrong.

      You initialized alias "RectA" with javascript "" (empty string). It means that alias "RectA" refers to nothing. The alias name is just a string. There's no way for the plugin to know that you meant javascript object named "RectA".

      So when you're later setting "RectA.left", you're actually setting "".left, which is just the global variable named "left". You also initialized alias "RectB" with an empty string. That's why RectB.left also means global variable named "left". Same variable. Actual javascript objects RectA, RectB and their properties stay unaltered.

      • Instead of

        Init ["RectA"] with javascript ""

        Init ["RectB"] with javascript ""

        Set ["RectA"] to 666

        You should do

        Init ["RectA"] with javascript "RectA"

        Init ["RectB"] with javascript "RectB"

        Set ["RectA"] to 666

        • Again. Init ["Alias"] with javascript "foo" means that the plugin will remember that wherever you're putting "Alias" when dealing with aliases, it actually means javascript object/variable/array foo. For example "Alias.left" means foo.left. "Alias[bar]" means foo[bar].

    • Can't reproduce the bug. Can you send me the sample project file with the bug?