Page 1 of 1

Running a script on a Variable Change

PostPosted: Thu Oct 19, 2017 5:41 pm
by chrisr
All, This is probably an easy answer, but can not find the solution, how would I go about running a script on a value change inside a variable. I need to write values to 10 other variables via a script which include some math. So basically a script that actively updates on the var update.

Thanks!!! Sorry for the basic question.

Chris

I currently am using TCP traffic and using the Action node. I'd rather use something that watches the Variable

Thanks a bunch for any input.

Re: Running a script on a Variable Change

PostPosted: Thu Oct 19, 2017 8:01 pm
by malkuth23
variable input node -> script output node

Re: Running a script on a Variable Change

PostPosted: Thu Oct 19, 2017 8:47 pm
by chrisr
Thanks so I guess I can do the IF Var1 = Var1 would continuously run the script I assume.

Matt, appreciate the input.

Re: Running a script on a Variable Change

PostPosted: Thu Oct 19, 2017 10:30 pm
by malkuth23
The script node will only run once when the if statement changes by default.
There is some checkbox on the bottom that I can not remember the words next to that will cause it to update at the refresh rate of the ui.

Re: Running a script on a Variable Change

PostPosted: Fri Oct 20, 2017 6:53 am
by Mike Mengen
You can also display the variable on a Label and use an Actionscript Node to trigger the script on Labelchange.

Re: Running a script on a Variable Change

PostPosted: Fri Nov 03, 2017 1:15 pm
by chrisr
Mike, would that be as a member value type of thing something like label1.labelchange ?

This is what is offered up by the action node, unless I can add things that aren't in the drop down list?

Image

Thanks!!

Re: Running a script on a Variable Change

PostPosted: Fri Nov 03, 2017 1:39 pm
by chrisr
There is some checkbox on the bottom that I can not remember the words next to that will cause it to update at the refresh rate of the ui.


Are you talking about the checkbox that says "GUI Delay" by it?

Re: Running a script on a Variable Change

PostPosted: Fri Nov 03, 2017 5:26 pm
by Thomas Mrozek
Hi all,
variable change as trigger for action script is already on our internal Feature wish list.
cheers

Re: Running a script on a Variable Change

PostPosted: Sat Nov 04, 2017 1:57 am
by Dennis Kuypers
Hello,

what or who is changing the variable? Maybe you can replace the variable assignment with a function/macro call?

That would be a more appropriate solution.

Regards
Dennis

Re: Running a script on a Variable Change

PostPosted: Mon Nov 13, 2017 12:15 pm
by Mike Mengen
Hi Chris,

sorry for the late response.
You would need Label1.Text
If the Text changes it will execute the Script.

Regards

Re: Running a script on a Variable Change

PostPosted: Wed Nov 15, 2017 3:28 pm
by chrisr
Mike, No Worries! You got me in the right direction, and it works great. Thank you very much.

Dennis, this is the project where I have a script running layers across a pixel space. (Which are being driven by incoming automation) When they reach the end, they reset to the beginning. I was looking for other alternatives to using the action node. (trying to make it as efficient as possible).

Thank you for all the help everyone!! its always appreciated.

Here is the script I'm using to manage this, this is only one of 2 of the many layers.

Code: Select all
L1 = TTa
IF L1 < L2
{
L2 = L1 + 1804
L2 = Math.Max (L2, 0)
}
ELSE
{
L2 -= 8.146
IF L2 <= 0
{
L2 = 23460
}
}

Re: Running a script on a Variable Change

PostPosted: Wed Nov 15, 2017 11:50 pm
by Dennis Kuypers
Hey,

Can you explain the values L1, L2, 8.146, 1804 and 23460 ?

You can use variables for constant values, this makes reading the script easier (and also allows you to change values in a lot of places at once)

Compare
Code: Select all
var x = y + 3840
VS
Code: Select all
var newPosition = oldPosition + SCREEN_WIDTH


(note that ALL_CAPS_SNAKECASE ist a convention that i like to use for constant values that are not supposed to be changed)

Regards
Dennis

Re: Running a script on a Variable Change

PostPosted: Thu Nov 16, 2017 6:53 pm
by chrisr
Dennis, I wrote some notes into this. Thank you for the other notes you gave as well.

Code: Select all
JUST a note on this, the layers are moving right to left. 
TTa is incoming automation value
Variables L1 - L13 are the X values in the Device layers in Pandora 1 - 13



L1 = TTa               // L1 is varible that holds x value of layer 1 in manager.  TTa is incoming automation value
IF L1 < L2
{
L2 = L1 + 1804            // +1804 is L2's offset from L1 (Master layer), each layer size is 1804 pixels, this offsets each device layer so they edge butt each other. L3's offset would be +3608
L2 = Math.Max (L2, 0)      // I was trying to keep the layers from going into negative space with this. not sure I need it now.
}
ELSE
{
L2 -= 8.146            // once L1 resets its self (its driven by incoming automation) L2 - L13 will keep moving but now at an incremental value that matches the automation resolution
IF L2 <= 0               // Once the individual layer hits zero, it is reset to the beginning of the pixel space. 
{
L2 = 23460            // If zero, it resets layer to far right of pixel space to start over again.
}
}
                  // Process repeats itself for another 11 layers.

IF L1 < L3
{
L3 = L1 + 3608
L3 = Math.Max (L3, 0)
}
ELSE
{
L3 -= 8.146
IF L3 <= 0
{
L3 = 23460
}
}

IF L1 < L4
{
L4 = L1 + 5412
L4 = Math.Max (L4, 0)
}
ELSE
{
L4 -= 8.146
IF L4 <= 0
{
L4 = 23460
}
}

IF L1 < L5
{
L5 = L1 + 7216
L5 = Math.Max (L5, 0)
}
ELSE
{
L5 -= 8.146
IF L5 <= 0
{
L5 = 23460
}
}

Re: Running a script on a Variable Change

PostPosted: Fri Nov 17, 2017 12:55 am
by Dennis Kuypers
Hello Chris,

if you have values constantly coming in and you have to send them out constantly you should probably be using the node system. This is more performant...at least I got a feeling that nodes are better suited ;)

A couple of Add nodes and using the Modulo node to wrap around will probably do.

Regards
Dennis

Re: Running a script on a Variable Change

PostPosted: Wed Dec 20, 2017 6:46 pm
by chrisr
All,
As usual, I was way over thinking this process. There were a few things I thought I had to build via a script that would create a scenario that would move device layers very specifically on the x axis. I wanted to move from left to right or right to left inside a pixel space, then when the layer reached a defined space it would start its move over again that the beginning of the pixel space. I had written a script that was being fired by a Script Output node that was watching an action node watching the Label attached to the incoming automation value. Everytime the label updated it would run the script.

Code: Select all
L1 = TTa
IF L1 < L2
{
L2 = L1 + 1804
L2 = Math.Max (L2, 0)
}
ELSE
{
L2 -= 8.146
IF L2 <= 0
{
L2 = 23460
}
}


After Speaking with Dennis and support team, via the forum and via email. Team described how a node structure would be way more efficient and way more performant. This was the node structure for the first two X-axis control layers The Master layer, and the second layer.

Image

These nodes allowed me to accomplish the above script only using three nodes. The Script nodes you see after are there to dissolve the layer off and on at the start and end of its movement. The incoming automation via Artnet, Modulo, and layer control accomplished the meat of what I was needing. I could plug in the values inside the modulo node to define the finish position which then would restart the layer at the start of the pixel space. Thanks everyone for chiming in on this. It was a brain twister for me. It really showed me how powerful the node structures are and how much more simple you can achieve your goal.... (though I'm sure not simple on the back end)...

Have a great Holiday everyone, thanks again!!