Connexion rapide:  

Forum: VirtualDJ Skins

Sujet on/off condition of button - Page: 1

Cette partie de ce topic est ancien et peut contenir des informations obselètes ou incorrectes

I've made a few buttons that i toggle on or off, but sometimes something goes wrong and the button will not light up when the button is pushed, but instead when turning off the button!

An example:

<button action="toggle '$ROCK' & var '$ROCK' ? var_equal '$LANGUAGE' 3 ? off & deck master sampler_pad 'Z:\OVERLAYS\Rocks.mp4' & sampler_loop 'Z:\OVERLAYS\Rocks.mp4' on : off & deck master sampler_pad 'Z:\OVERLAYS\Rock.mp4' & sampler_loop 'Z:\OVERLAYS\Rock.mp4' on : var_equal '$LANGUAGE' 3 ? on & deck master sampler_pad 'Z:\OVERLAYS\Rocks.mp4' : on & deck master sampler_pad 'Z:\OVERLAYS\Rock.mp4'">

Is there another way of controlling the button light, maybe with a condition?
 

Posté Tue 04 Oct 16 @ 3:01 pm
djdadPRO InfinityDevelopment ManagerMember since 2005
There are 4 cases/conditions there with on and off in the action. Doesnt the LED respect those on/off ?
Try this..
action="toggle '$ROCK' && var '$ROCK' ? ......

If you want to explicitly define the behavior of a LED, you can add query="vdjscript" to the <button>
E.g. <button action="Here you define what the button does" query="Here you define how the LED behaves"

Btw, the action above actually makes the LED to follow the $ROCK variable status but in a reversed order, so OFF when variable is true and ON when false
 

Posté Tue 04 Oct 16 @ 3:21 pm
No LEDs, just skin buttons, Babis :)

I tried the double "&" and there was no diffference: the first touch seems to do nothing, then at the second touch (which turns the skin button light off) the video loop plays. except that now the light doesn't work at all (with the double "&").

Yes, I always found that very strange, ever since VDJ7's vdjscript. The "on" and "off" verbs were always counter-intuitive for me: they state the situation prior to the action, instead of the change when the action takes place... I ALWAYS had to write it like this to get the buttons to turn on when activated...

Never used the query verb yet. I'll look into that. Thanks!

EDIT: I cannot find the "query" verb on the VDJscript page of this site...
 

Posté Tue 04 Oct 16 @ 3:35 pm
djdadPRO InfinityDevelopment ManagerMember since 2005
I know its not abut a controller, since you posted in the Skin Forum :)
By LED i meant that the button on a skin can behave exactly like a button on a controller, so you have the ability to just define an action and let the "LED"/skin button to follow the true/false state of the action or you can split that by adding query="" to your skin button.

So your skin button can be ...
<button action="toggle '$ROCK' & var '$ROCK' ? var_equal '$LANGUAGE' 3 ? deck master sampler_pad 'Z:\OVERLAYS\Rocks.mp4' & sampler_loop 'Z:\OVERLAYS\Rocks.mp4' on : deck master sampler_pad 'Z:\OVERLAYS\Rock.mp4' & sampler_loop 'Z:\OVERLAYS\Rock.mp4' on : var_equal '$LANGUAGE' 3 ? deck master sampler_pad 'Z:\OVERLAYS\Rocks.mp4' : deck master sampler_pad 'Z:\OVERLAYS\Rock.mp4'" query="var '$ROCK' ? off : on">
With the above, the button will still execute the same action, and will use the <on> or <selected> grahics when the query="" provides true, so in the example, when the variable $ROCK is 0.

In the above, i removed the on/off from the action and added a very simple action to the query part.
In the query part, you can have e.g query="play ? blink : on" or whatever you want the LED/skin button to behave as
 

Posté Tue 04 Oct 16 @ 5:54 pm
Thank you very much for this detailed and clear description. I hope other people can benefit from this as well.

Just one thing: all variables are at 0 value when the program is started, so shouldn't the button when activated change this value to 1 (you said 0)?
 

Posté Tue 04 Oct 16 @ 8:04 pm
Never mind. I see the confusion (because of the way i wrote the old code).
:)
 

Posté Tue 04 Oct 16 @ 9:12 pm
As I understand it, the best way to make a skin button in VDJ 8 light up is the query method.

But I have to report a small "bug" that prevents the button to light up at the first push, and thus makes the button light up at the second push (when the action is turned off). As far as i have been able to determine, this happens when the action to be performed is slow (takes time). I have noticed this wrong button light behaviour in buttons that trigger the sampler pad.

This is an example (the button also checks another condition which has to do with languages, but that doesn't concern the problem):

<button action="toggle '$ROCK' & var '$ROCK' ? var_equal '$LANGUAGE' 3 ? deck master sampler_pad 'Z:\OVERLAYS\Rocks.mp4' & sampler_loop 'Z:\OVERLAYS\Rocks.mp4' on : deck master sampler_pad 'Z:\OVERLAYS\Rock.mp4' & sampler_loop 'Z:\OVERLAYS\Rock.mp4' on : var_equal '$LANGUAGE' 3 ? deck master sampler_pad 'Z:\OVERLAYS\Rocks.mp4' : deck master sampler_pad 'Z:\OVERLAYS\Rock.mp4'" query="var '$ROCK' ? on : off">

Babis, are you aware of this misbehaviour when the button doesn't do what it is supposed to do at the first push/click?

I say Babis, but I mean any of the VDJscript experts on this forum, of course ;)
 

Posté Tue 18 Oct 16 @ 11:29 am
locoDogPRO InfinityModeratorMember since 2013
try switching your "on:off" at the end round
 

Posté Tue 18 Oct 16 @ 12:20 pm
First of all try
query="var '$ROCK'"

Second:
On a custom button assign the following command: var_list
Then use this button to check the states of your variables.

If on that list your variable is set, but your button does not light up then it's a bug, but I don't think such a bug exists in the skin engine since I use it all the time on my skins...

Depending on how you treat your vars on complex scripts, there's a good chance you "messed" something up and your scripts work with their vars inverted. In other words they work when you think a var is set, but they actually work when the var is not set...
 

Posté Tue 18 Oct 16 @ 12:41 pm
Thanks for your input guys!

@ locodog: that would be a workaround IF it would ALWAYS be the case that the first touch is ignored. But this is not so. There are times (very few, I admit) that the button does work as it is supposed to.

@ PhantomDeejay: I don't need to know the state, because I can see if the video is playing or not, just like I can see whether the button is lit or not ;)
I don't know what you mean by try "..." because your code is the same as mine... (?)

 

Posté Thu 20 Oct 16 @ 1:36 pm
locoDogPRO InfinityModeratorMember since 2013
Write your script as a logic tree and consider everything that could change the logic, errors in the script engine do occur but you can usually narrow it down to a single verb.
 

Posté Thu 20 Oct 16 @ 2:02 pm
I did what you suggested, locodog, and made a logic tree (had to look that one up in wikipedia, lol) and the formula seems to have a sound logic flow:

BUTTON:
FIRST PUSH ? VARIABLE ROCK ON
TWO LANGUAGES ? START DUAL VIDEO + LOOP
ONE LANGUAGE ? START NORMAL VIDEO + LOOP
SECOND PUSH ? VARIABLE ROCK OFF
TWO LANGUAGES ? STOP DUAL VIDEO
ONE LANGUAGE ? STOP NORMAL VIDEO
QUERY:
VARIABLE ROCK ON ? BUTTON LIT
VARIABLE ROCK OFF ? BUTTON UNLIT

 

Posté Thu 20 Oct 16 @ 3:52 pm
Even with the query verb, the button fails on me. I insist that it's because of a slight delay in loading a videoclip into the sampler, because it only happens with those button that do just that. The first (turn on) push of the button simply isn't recognized, making the button light up at the second (turn off) push. Even with the query verb.
 

Posté Fri 28 Oct 16 @ 10:43 pm
AdionPRO InfinityCTOMember since 2006
If you want to make sure the query checks for a specific sample, then that is what you should put in there.

If you want the sample to be ready without delay, add it to a sample bank and make sure it is selected. That way you can trigger it instantly.
 

Posté Sat 29 Oct 16 @ 4:59 am
That's the answer, Adion! I've been querying the state of the variable that I trigger when pushing the button, but I could instead query if the sample is playing! Now why didn't I think of that? I'll go and try it out right now! Many thanks!
 

Posté Sat 29 Oct 16 @ 8:16 am
Okay, so I'm pretty new at this query stuff... I seem to be unable to get the right phrasing and cannot find a relevant example of the query use on this site.

I have these four kinds of buttons...

1. TURN EFFECT ON AND OFF:

<button action="toggle '$VISUALS' & var '$VISUALS' ? deck master effect_active 'milkdrop8' on : deck master effect_active 'milkdrop8' off" query="var '$VISUALS' ? on : off">

2. PLAY SAMPLE:

<button action="toggle '$COLORFX' & var '$COLORFX' ? deck master sampler_pad 'Z:\OVERLAYS\ColorFX.mp4' : deck master sampler_pad 'Z:\OVERLAYS\ColorFX.mp4'" query="var '$COLORFX' ? on : off">

3. PLAY A DIFFERENT SAMPLE EACH TIME THE BUTTON IS TURNED ON:

<button action="toggle '$SHADOW' & var '$SHADOW' ? sampler_bank 'SHADOW' & sampler_select +1 & deck master sampler_play : sampler_bank 'SHADOW' & deck master sampler_stop" query="var '$SHADOW' ? on : off">

4. PLAY SAMPLE A OR B LOOPED (DEPENDING ON THE LANGUAGE OF THE SHOW):

<button action="toggle '$DISCO' & var '$DISCO' ? var_equal '$LANGUAGE' 3 ? deck master sampler_pad 'Z:\OVERLAYS\Discos.mp4' & sampler_loop 'Z:\OVERLAYS\Discos.mp4' on : deck master sampler_pad 'Z:\OVERLAYS\Disco.mp4' & sampler_loop 'Z:\OVERLAYS\Disco.mp4' on : var_equal '$LANGUAGE' 3 ? deck master sampler_pad 'Z:\OVERLAYS\Discos.mp4' : deck master sampler_pad 'Z:\OVERLAYS\Disco.mp4'" query="var '$DISCO' ? on : off">

...and I have to change the last bit (query) into something that asks if the effect is active or if the sample is playing...

None of the script phrasings I tried work. What would the correct syntax for these buttons be?

And that fourth button would need two queries, right? How can I do that?

 

Posté Sat 29 Oct 16 @ 8:39 am
AdionPRO InfinityCTOMember since 2006
"sampler_pad 'Z:\OVERLAYS\Disco.mp4'" when used in a query would light up exactly as the button on the sampler would.
 

Posté Sat 29 Oct 16 @ 8:44 am
That's correct. So the second button (play a sample) syntax is answered. But the button number four doesn't light up when I have the language variable active and the other sample Discos.mp4 should be playing... Hence my question: how do I go about writing two queries? One for the Disco.mp4 and one for the Discos.mp4...
 

Posté Sat 29 Oct 16 @ 8:52 am
AdionPRO InfinityCTOMember since 2006
The same way as in an action:
var_equal '$LANGUAGE' 3 ? sampler_pad 'Z:\OVERLAYS\Discos.mp4' : sampler_pad 'Z:\OVERLAYS\Disco.mp4'
 

Posté Sat 29 Oct 16 @ 8:57 am
It works! I don't understand the logic behind the query formulation, but it works!

Thank you Adion!

Could you also help me with button types 1 and 3?

Following your logic, query="effect_active 'milkdrop8' on ? on : off" should work, but it doesn't turn the button on...

And those rotating sample buttons are even more difficult, since a different sample is playing each time the button is turned on...

This: query="sampler_bank 'SHADOW' & sampler_select +1 & deck master sampler_play ? on : off", has the button turned on always...
 

Posté Sat 29 Oct 16 @ 9:01 am
74%