Ingreso rápido:  

Forum: VirtualDJ Technical Support

Tema: VDJScript: different button behavior in PADS
Hi. I'm getting new to VDJScript. Enter the code into the PADS in two buttons. Why is 'action' different for buttons?
button 1
get_var 'action' &
(holding ?
set 'Holding' 1 & var_list :
set 'Holding' 0 & var_list) &
var 'Holding' ?
set 'action' 1 & var_list :
set 'action' 0 & var_list

button2
get_var 'action' &
holding ?
set 'action' 1 & var_list :
set 'action' 0 & var_list
 

Mensajes Wed 01 Jun 22 @ 8:24 pm
locoDogPRO InfinityModeratorMember since 2013
don't use holding in brackets.
 

Mensajes Wed 01 Jun 22 @ 8:30 pm
 

Mensajes Wed 01 Jun 22 @ 8:51 pm
I can't imagine this script without (**) (so I can, but its length will be triple and its extension very difficult)

get_var 'DeckSlideShowActive' &
(holding ?
set 'HoldingKeySlideShow' 1 :
var 'DeckSlideShowActive' ?
set 'HoldingKeySlideShow' 0 :
set 'HoldingKeySlideShow' 1) &
var 'HoldingKeySlideShow' ?
repeat_start_instant 'RD_SlideShow' 500ms &
var 'HoldingKeySlideShow' ?
set 'HoldingKeySlideShow' 0 &
(video_fx_select "Slideshow" && video_fx) ?
repeat_stop 'RD_SlideShow' &
video_fx_select "none" & video_fx & set 'DeckSlideShowActive' 0 :
(video_fx_select "Slideshow" && is_video) ?
repeat_stop 'RD_SlideShow' &
video_fx_select "none" & video_fx & set 'DeckSlideShowActive' 0 :
repeat_stop 'RD_Shader' &
set 'DeckSlideShowActive' 1 & set 'DeckShaderActive' 0 &
(video ? nothing : video) &
video_fx_select "Slideshow" &
is_video ?
nothing :
video_fx :
video ?
(video_fx_select "Slideshow" && video_fx) ?
nothing :
is_video ?
nothing :
video_fx_select "Slideshow" & video_fx :
repeat_stop 'RD_SlideShow' & video_fx_select "none" &
set 'DeckSlideShowActive' 0 :
effect_button 'Slideshow' 6
 

Mensajes Wed 01 Jun 22 @ 9:34 pm
locoDogPRO InfinityModeratorMember since 2013
that won't work, outside of the first brackets will be performed almost instantly, certainly before holding has time to set HoldingKeySlideShow to 1.

You need to rethink it.

 

Mensajes Wed 01 Jun 22 @ 9:55 pm
It's exactly how you write. What is the reason why he doesn't have time to set HoldingKeySlideShow to 1? Is it written somewhere that explains this behavior? I thought that the first condition would be executed first and then the rest of the script would be executed.

This script works fine.
get_var 'DeckSlideShowActive' &
holding ?
set 'HoldingKeySlideShow' 1 &
repeat_start_instant 'RD_SlideShow' 500ms &
var 'HoldingKeySlideShow' ?
set 'HoldingKeySlideShow' 0 &
(video_fx_select "Slideshow" && video_fx) ?
set 'x' 1 & var_list &
repeat_stop 'RD_SlideShow' &
video_fx_select "none" & video_fx & set 'DeckSlideShowActive' 0 :
(video_fx_select "Slideshow" && is_video) ?
set 'x' 2 & var_list &
repeat_stop 'RD_SlideShow' &
video_fx_select "none" & video_fx & set 'DeckSlideShowActive' 0 :
set 'x' 3 & var_list &
repeat_stop 'RD_Shader' &
set 'DeckSlideShowActive' 1 & set 'DeckShaderActive' 0 &
(video ? nothing : video) &
video_fx_select "Slideshow" &
is_video ?
nothing :
video_fx :
video ?
(video_fx_select "Slideshow" && video_fx) ?
nothing :
is_video ?
nothing :
video_fx_select "Slideshow" & video_fx :
repeat_stop 'RD_SlideShow' & video_fx_select "none" & video_fx &
set 'DeckSlideShowActive' 0 :
effect_button 'Slideshow' 6
 

Mensajes Fri 03 Jun 22 @ 7:17 am
What you need to understand (without me going through your code) is this:

action=(a) & (b)

In this case a & b are run one after another. "b" does not wait "a" to do something.
While the execution is not technically paraller but sequential, you should consider it as parallel.

So, in your case in the "a" block you have a "holding ?" statement.
The holding script introduces a 1000ms delay before it gets executed.
Therefore, by the time the "holding ?" script toggles your variable, the code on "b" block has long ago finished executing.

I hope this clears up things a little.
 

Mensajes Fri 03 Jun 22 @ 7:34 am
AdionPRO InfinityCTOMember since 2006
What you write within brackets is independent from the rest of the script, so
(holding ? a : b) & (c)
c does not depend on holding so can be executed immediately
a or b will depend on holding, which is only known on release or after some time.

Since we now have brackets in script, I'm not sure why bother with using a var to remember if holding is used or not in the first place.
You can simplify all of that using
holding ? (a & b & c) : (d & e & f)
 

Mensajes Fri 03 Jun 22 @ 7:40 am

I'm a developer in C and C ++, so I'm beginning to know where the problem is (thread processing), but I'd like to read about this problem when scripting. Your post inspired me to edit a script that works.

get_var 'DeckSlideShowActive' &
(holding 200ms ?
set 'HoldingKeySlideShow' 1 :
var 'DeckSlideShowActive' ?
set 'HoldingKeySlideShow' 0 :
set 'HoldingKeySlideShow' 1) &
wait 210ms &
var 'HoldingKeySlideShow' ?
repeat_start_instant 'RD_SlideShow' 500ms &
var 'HoldingKeySlideShow' ?
set 'HoldingKeySlideShow' 0 &
(video_fx_select "Slideshow" && video_fx) ?
repeat_stop 'RD_SlideShow' &
video_fx_select "none" & video_fx & set 'DeckSlideShowActive' 0 :
(video_fx_select "Slideshow" && is_video) ?
repeat_stop 'RD_SlideShow' &
video_fx_select "none" & video_fx & set 'DeckSlideShowActive' 0 :
repeat_stop 'RD_Shader' &
set 'DeckSlideShowActive' 1 & set 'DeckShaderActive' 0 &
(video ? nothing : video) &
video_fx_select "Slideshow" &
is_video ?
nothing :
video_fx :
video ?
(video_fx_select "Slideshow" && video_fx) ?
nothing :
is_video ?
nothing :
video_fx_select "Slideshow" & video_fx :
repeat_stop 'RD_SlideShow' & video_fx_select "none" &
set 'DeckSlideShowActive' 0 :
effect_button 'Slideshow' 6
 

Mensajes Fri 03 Jun 22 @ 8:05 am
thanks, I think that explains it all.
 

Mensajes Fri 03 Jun 22 @ 10:32 pm