[Plugin] Hash table

  • https://jsperf.com/objectsashashes

    seems that complexity is still O(1) for all, but real performance (in Opera) is solid, except for destroying - where it's bad.

  • I rewrote the document. Now this plugin is supported again.

  • Update

    Add rex_bHash behavior, a behavior version of hash table (JSON).

  • Can i use "JSONPath"? Like "XPath"?

  • andykenobi

    In Expression:At( keys ) , designer can use dot notation to represent the node path, for example

    [quote:dzd94krb]{ "a": { "b" : 10 }, "c":20 }

    Expression:At( "a.b" ) will return 10.

  • andykenobi

    In Expression:At( keys ) , designer can use dot notation to represent the node path, for example

    [quote:1vdjdiai]{ "a": { "b" : 10 }, "c":20 }

    Expression:At( "a.b" ) will return 10.

    Hum, but i want to get another value... like this XML:

    XML.StringValue("/translate/"en-us"/General/text/text()")

  • andykenobi

    This feature is not supported.

  • Hi rex,

    Thanks so much for your plugin.

    I found an issue : CurValue("a.b") does not work. Construct 2 says that it doesn't accept parameters even though the description says that it does.

  • Update

    Fix bug of parameter assignment in expression:CurValue

    Sample capx

    Fixed, thanks for bug reporting.

  • hello rex,

    in the behavior verson of the add on.

    if you have multiple instances of an object, the "for each" condition does not iterate over them correctly.

    it can be fixed by writing "system.forEach(obj)"

    here is a simple example:

    https://ibb.co/j0jmVv

  • im trying to change this part of the code, to make it go for each instance

    any ideas?

     Cnds.prototype.ForEachItem = function (key) {
            var entry = this.getEntry(key);
    
            var current_frame = this.runtime.getCurrentEventStack();
            var current_event = current_frame.current_event;
            var solModifierAfterCnds = current_frame.isModifierAfterCnds();
    
            var key, value;
            this.exp_Loopindex = -1;
            for (key in entry) {
                if (solModifierAfterCnds)
                    this.runtime.pushCopySol(current_event.solModifiers);
    
                this.exp_CurKey = key;
                this.exp_CurValue = entry[key];
                this.exp_Loopindex++;
                current_event.retrigger();
    
                if (solModifierAfterCnds)
                    this.runtime.popSol(current_event.solModifiers);
            }
    
            this.exp_CurKey = "";
            this.exp_CurValue = 0;
            return false;
        };
    [/code:1q7zkkqn]
  • sagispin

    "Condition: For each key" of behavior JSON won't pick instance (sprite), therefore Each "Expression: Sprite.JSON.CurValue" will point to first sprite. You could print expression: Sprite.UID to see the picked instance of expression.

    Add "system.forEach(obj)" is solution indeed.

  • sagispin

    "Condition: For each key" of behavior JSON won't pick instance (sprite), therefore Each "Expression: Sprite.JSON.CurValue" will point to first sprite. You could print expression: Sprite.UID to see the picked instance of expression.

    Add "system.forEach(obj)" is solution indeed.

    i manged to fix it - my style -> editing the add on:

        Cnds.prototype.ForEachItem = function (key) {
            // === NEW ===
            var sol = this.type.objtype.getCurrentSol();
            sol.select_all = false;
            cr.clearArray(sol.instances);
            sol.instances[0] = this.inst;
            // ===========
    
            var entry = this.getEntry(key);
            var current_frame = this.runtime.getCurrentEventStack();
            var current_event = current_frame.current_event;
            var solModifierAfterCnds = current_frame.isModifierAfterCnds();
    
            var key, value;
            this.exp_Loopindex = -1;
            for (key in entry) {
                if (solModifierAfterCnds)
                    this.runtime.pushCopySol(current_event.solModifiers);
    
                this.exp_CurKey = key;
                this.exp_CurValue = entry[key];
                this.exp_Loopindex++;
                current_event.retrigger();
    
                if (solModifierAfterCnds)
                    this.runtime.popSol(current_event.solModifiers);
    
            }
            this.exp_CurKey = "";
            this.exp_CurValue = 0;
            
            // === NEW ===
            sol.select_all = false;
            cr.clearArray(sol.instances);
            // ===========
    
            return false;
        };
    [/code:3n27vui3]
    
    took my around 2 hours
  • Try Construct 3

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

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

    You could modify it. but I won't. Because that condition should not modify SOL ideally.

  • this is just my way of overcoming this potensial bug:

    https://ibb.co/j0jmVv

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