[Plugin] Hash table

Post your completed addons to share with the community

Post » Mon Aug 08, 2016 2:27 pm

@andykenobi

In Expression:At( keys ) , designer can use dot notation to represent the node path, for example
{ "a": { "b" : 10 }, "c":20 }

Expression:At( "a.b" ) will return 10.
B
108
S
26
G
271
Posts: 4,471
Reputation: 151,777

Post » Mon Aug 08, 2016 2:37 pm

rexrainbow wrote:@andykenobi

In Expression:At( keys ) , designer can use dot notation to represent the node path, for example
{ "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[@id='"& txtID.Id &"']/text()")
B
14
S
6
G
2
Posts: 81
Reputation: 2,241

Post » Mon Aug 08, 2016 3:10 pm

@andykenobi

This feature is not supported.
B
108
S
26
G
271
Posts: 4,471
Reputation: 151,777

Post » Fri Dec 23, 2016 3:39 pm

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.
B
20
S
9
G
3
Posts: 41
Reputation: 3,126

Post » Fri Dec 23, 2016 5:07 pm

Update

Fix bug of parameter assignment in expression:CurValue
Sample capx


@Abdellah

Fixed, thanks for bug reporting.
B
108
S
26
G
271
Posts: 4,471
Reputation: 151,777

Post » Mon Jun 12, 2017 4:12 pm

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
Image
B
41
S
16
G
7
Posts: 55
Reputation: 6,498

Post » Tue Jun 13, 2017 10:59 am

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

Code: Select all
 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;
    };
B
41
S
16
G
7
Posts: 55
Reputation: 6,498

Post » Tue Jun 13, 2017 12:45 pm

@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.
B
108
S
26
G
271
Posts: 4,471
Reputation: 151,777

Post » Tue Jun 13, 2017 1:05 pm

rexrainbow wrote:@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:

Code: Select all
    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;
    };


took my around 2 hours
B
41
S
16
G
7
Posts: 55
Reputation: 6,498

Post » Tue Jun 13, 2017 1:18 pm

@sagispin

You could modify it. but I won't. Because that condition should not modify SOL ideally.
B
108
S
26
G
271
Posts: 4,471
Reputation: 151,777

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 3 guests