Ingreso rápido:  

Forum: VirtualDJ Technical Support

Tema: Enable/Disable a color rule via VDJ script?
seanPRO InfinityMember since 2018
I'd like to Enable/Disable a color rule via VDJ script. I was attempting to do this via a skins ONINIT so that every time I change skins the rule is enabled or disabled. Does anyone know a way to achieve this. Everything I've seen so far leads me to believe it isn't possible.

 

Mensajes Sun 03 Nov 24 @ 12:56 pm
locoDogPRO InfinityModeratorMember since 2013
I don't think it is, you can't access the setting with script.

A quick thought on it, ideally the color rules popup could/should have an 'active' checkbox, then something like this would make sense [not a real script]
color_rule 1 on|off
 

Mensajes Sun 03 Nov 24 @ 1:07 pm
seanPRO InfinityMember since 2018
Yeah, I guess it'd be similar to the quick_filter verb.

Alternatively adding a color rule via a script. Something like add_color_rule <position> <color> <rule> would be great.
 

Mensajes Sun 03 Nov 24 @ 1:19 pm
AdionPRO InfinityCTOMember since 2006
You can access scripts from a color rule though, so you can check if a variable is set in the color rule, and then change that variable to enable/disable the rule
 

Mensajes Sun 03 Nov 24 @ 1:30 pm
locoDogPRO InfinityModeratorMember since 2013
Can you?
Tried this and the rule failed
Already Played = 1 and `var_equal '$aaa' 1`
 

Mensajes Sun 03 Nov 24 @ 1:50 pm
seanPRO InfinityMember since 2018
That'd be a game changer! I've just spent some time playing with various syntaxes and can't seem to figure out how to do it, and can't seem to find any reference on the forums?
 

Mensajes Sun 03 Nov 24 @ 2:04 pm
AdionPRO InfinityCTOMember since 2006
Sorry, indeed not entirely.
Scripts do work after the operation though, so I think you could hack it a little bit
Already Played >= `var '$aaa'`
Then you can set $aaa to 0 if you want the rule to apply, and -1 otherwise
 

Mensajes Sun 03 Nov 24 @ 2:24 pm
seanPRO InfinityMember since 2018
Thanks for the example, unfortunately it's not working on my end. Be interested to know if anyone else has any luck with it.
 

Mensajes Sun 03 Nov 24 @ 3:18 pm
locoDogPRO InfinityModeratorMember since 2013
Yeah that works, kind of tricky.

Sean can you give me a couple of your rules, from before attempts, I'll see what I can come up with

Realistically I can only come up with 2 "conditions" using Already played.
I think I recently suggested a more straight forward
True Query, type of filter

I made this, key being the actual thing you want to colour for, and if you want to switch this filter off you set $aaa to anything other than 1|0
pretty complicated, I'll try think on it a bit, there might be a simpler way.

Key is 01A and ( Already Played = `param_equal 'get_var $aaa' 0 ? get_constant 0 : get_constant 2` or  Already Played = `param_equal 'get_var $aaa' 1 ? get_constant 1 : get_constant 2` )


Could maybe get 3 conditions, but this has baked my brain a little.

I don't want to typo correct the CTO but I think for Adion's rule it needs to be <=
 

Mensajes Sun 03 Nov 24 @ 4:19 pm
AdionPRO InfinityCTOMember since 2006
Indeed possible that >= doesn't work with Already Played.
I think you canuse another numeric field though like nbplay, which would either be >=0 but never <0
 

Mensajes Sun 03 Nov 24 @ 4:28 pm
locoDogPRO InfinityModeratorMember since 2013
it works you meant <=
 

Mensajes Sun 03 Nov 24 @ 4:33 pm
locoDogPRO InfinityModeratorMember since 2013
3 conditions, used key as example, must be wrote in this order

Usual filtering from fresh start [ var $aaa can be 0 | 1 ]
Key is 01A and ( Already Played = `param_equal 'get_var $aaa' 0 ? get_constant 0 : get_constant 2` or  Already Played = `param_equal 'get_var $aaa' 1 ? get_constant 1 : get_constant 2` )


one Condition
set $aaa to set $aaa 0 & set $aaa -1
Key is 01A and Already Played > `get_var '$aaa'`


the other condition
set $aaa to set $aaa 2
Key is 01A and Already Played < `get_var '$aaa'`
 

Mensajes Sun 03 Nov 24 @ 6:21 pm
seanPRO InfinityMember since 2018
Well done Locodog, that logic took me a couple hours to get my head around. Thanks a heap for your help.

Adion, I noticed in your example you were using var '$aaa' turns out it has to be get_var '$aaa'.

Please correct me if I'm wrong, but here's some details for anyone else reading this post. The reference in Locodogs example to Already Played is only there as a placeholder, we don't really want to check its value. We're just using that as a way to turn the color rule on/off. But in my case Already Played was problematic because as I played tracks the value of it was changing which was turning the rules on/off. So instead it might be better to choose another rule which doesn't change, I figured Exists was good?

If you're interested in my use case I had a color rule Days since Last Play < 0.2083. Which marks a song red if played in the last 5 hours. This is better than using "Already Played" because I sometimes play songs twice in long sets. If I played it more than 5 hours ago my audience has changed. However I wanted to turn this off when I'm not at gigs because when I'm preparing music I like to see my other color rules.

I ended up with this rule:
Days since Last Play < 0.2083 And Exists = `get_var '$performing'`


And then I simply toggle a var $performing between 1 and 0.

You can also pass a value directly Days since Last Play < `get_var '$last_play'`
 

Mensajes Mon 04 Nov 24 @ 7:58 am
AdionPRO InfinityCTOMember since 2006
That's why using Already Played, but with >= should work when toggling the variable between -1 and 0
Already Played will be 0 or 1, so >=-1 will always be false, and >=0 will always be true, regardless of the track actually being played or not
 

Mensajes Mon 04 Nov 24 @ 8:06 am