Quick Sign In:  

Forum: General Discussion

Topic: Script School - Page: 1.35

This part of topic is old and might contain outdated or incorrect information

locodogPRO InfinityModeratorMember since 2013
Lesson 3
Moving on to FX

First a word about fx slots, what are they and why do we have then.
Imagine you had some sort of mega controller that had many many dials, that would be cool in a way, every dial could do just one job.

You could just script the hw dial directly to the sw dial of your choice, something like this
effect_slider "echo" 1
So your hw dial always controls the first slider of the echo fx.
But such a controller doesn't really exist.
So we need to have fx slots so the hw dial can control different sw dials depending on what we are doing.

The default skin can show 1 or 3 fx slots BUT as with many things in vdj, just because it isn't on the skin doesn't mean you can't use it (imagine using a 2 deck skin and a 4 deck controller, you can still use decks 3 & 4 even though they are invisible, ninja)

So any way a usual script on a controller dial for a fx slot slider is like this
effect_slider 3 2
We want to control a slider on the 3rd fx slot and we want it to be the 2nd slider.

Ok lets expand on what we know and learn about what parameters various scripts can take.

effect_active
[1st optional param is slot number]
[2nd optional param is fx name in quotes " "]
[3rd optional param is on/off or 1/0]

If you don't specify a slot but specify a name the fx doesn't get a slot. It still works

If you specify the 1st & 3rd it will turn the slot given on or off
If you specify the 2nd only, it will toggle the fx regardless if it is on a slot or not
If you specify the 1st & 2nd, it will put that effect on that slot and toggle it.
If you specify 2nd & 3rd it will switch the fx to the 3rd regardless if it is slotted or not.

If you specify just the 3rd then vdj doesnt know its the 3rd param, its only seen one param so it asumes its the 1st

I'm going to write up more on each of the effect_X scripts and the params they can take, but for now that will do.
 

Posted Tue 29 May 18 @ 6:36 pm
VDJ RonPRO InfinityMember since 2010
<map action="var '$shift' ? beat_tap : key_lock" value="KEYLOCK"/>

<map action="var_equal '$shift' 0 ? touchwheel_touch : nothing" value="JOG_TOUCH"/>

<map action="var_equal '$shift' 0 ? touchwheel : param_smaller 0 ? adjust_cbg -1% : adjust_cbg +1%" value="JOG"/>


Above is an extract from a controller mapping. Originally the jog controlled the sampler volume. I did not need that and so adapted the script for cbg adjustment. It was a case of monkey sees and does. I don't understand why '$shift' 0 is used instead of '$shift' as in the first line of the mapping extract.
It does work on my controller.
Since recently changing my sub controller I've had enough buttons to do pads, samples and more. Hence I've only just started using pads so I overlooked your useful addon. Mind you I could have put it on my keyboard. I brought this issue up because rapid cbg adjustment has become more and more important.

Note You can put this script on any available endless encoder.
 

Posted Wed 30 May 18 @ 7:21 am
That's how you should map the elements "correctly":

<map action="var_equal '$shift' ? nothing : touchwheel_touch" value="JOG_TOUCH"/>
<map action="var_equal '$shift' ? param_smaller 0 ? adjust_cbg -1% : adjust_cbg +1% : touchwheel" value="JOG"/>

BTW: For MOST controller the above scripts can be like this from version 8.2 onwards:
<map value="KEYLOCK" action="key_lock" />
<map value="SHIFT_KEYLOCK" action="beat_tap" />
<map value="JOG_TOUCH" action="touchwheel_touch" />
<map value="SHIFT_JOG_TOUCH" action="nothing" />
<map value="JOG" action="touchwheel" />
<map value="SHIFT_JOG" action="adjust_cbg" />
 

Posted Wed 30 May 18 @ 7:40 am
locodogPRO InfinityModeratorMember since 2013
var '$shift' ? Is the same as asking var_greater '$shift' 0 ?
not including a value in the first is just a short hand, sometimes vars are used as on/off flags (like $shift is) and no value, querying >0 is fine
Other times when a var has several possible values it is better to query against a number, but no number queries in some circumstances may be useful.

1 guess is the jog wheel script queries
var '$shift' 0 ?
So the true/false replies are in an order to make more sense to beginners
I'm just using the jog, the first reply is that,
I'm using the jog with shift, the second reply is this.

More likely it could be just down to how the mapping was written,

The atomix hardware guys have done loads of mappings and won't work as a user does, (mapping insided vdj one command at a time) no they'll do it all in np++ the whole mapping in one go and then test in vdj

Just one of those things you do to be efficient.

Touching the jog without shift will always just script to touchWheel, but with shift the function may change or the values may need to be tweaked, therefore it's easier to have the bit that may change at the end of a script, instead of having it as the 1st reply, somewhere in the middle of the script.

Edit, thanks phantom.
ah yes v8.2 now creates shift+entryName entry names, it does make life easier.
 

Posted Wed 30 May 18 @ 8:00 am
VDJ RonPRO InfinityMember since 2010
Thxs Phantom..I'll try your improvements. I'm using an old mc3000 for small venues and need good cbg control.
..and thxs Locodog.
 

Posted Wed 30 May 18 @ 8:00 am
locodogPRO InfinityModeratorMember since 2013
Ok lets move on to, effect_select & effect_select_multi.
These do a similar action except one small difference.

Say you have an effect actually on and running on slot 1, say reverb.

If you use the script " effect_select 1 'echo' "
It will do 2 things, first it will turn off the fx currently on slot 1 (we said reverb), second it will put the echo fx on slot 1 but the echo will not be on,

If you use the script " effect_select_multi 1 'echo' "
echo will go on slot 1, (again still not on) but the fx on slot 1 (reverb 'member...?) As before echo will not be switched off.

Right since they are so similar I'll only cover the params for effect_select, multi performs the same.

effect_select
[1st optional param is slot number]
[Alternative 1st param can be "video" in quotes to change in the video fx slot]
[2nd optional param is fx name in " "s]
[Alternative 2nd param can be a number, 0 will take you to the very first fx you have in your list, 1 will go to the last fx, if you include a + or - it will move from the current position]
Example effect_select 3 +1, move down the list 1 item for slot 3

If you use effect_select on it's own then a popup for slot 1 will appear and you can use your browser encoder/browser button to pick a fx (keyboard up/down arrows + enter work too)
If you use effect_select 2, it will popup for slot 2

If you use effect_select "echo" echo will go on slot 1
If you use a slot number and fx name the fx goes on the chosen slot

Effect_select (and multi) is useful to get fx on slot so you can check sliders are ok before starting it with effect_active (we've covered this)
But in some cases you don't need to check the sliders as you can script all the sliders and buttons to your perfect settings, (buttons & sliders covered in maybe 2 lessons time)

Right then next lesson will be a real world example of how I select fx from my launchpad, the mistakes I made, how I got around them.

Later still i will write how I will rewrite the mapping when i start from scratch. But we'll have to cover the basics of variables first.
 

Posted Mon 04 Jun 18 @ 1:36 am
locodogPRO InfinityModeratorMember since 2013
A tiny bit about variables and shift.
Variables are how vdj remembers numbers, previously in vdj your shift button toggled a variable either 1 when pressed 0 when released.

After a time vdj simplified this variable to a single verb
shift
We see shift, deep under the hood of vdj it sees
'$shift' ? Yes : no
Back then to get a shift & button to give you a different result you had to query the variable.

Say you wanted to have shift + play = reverse
Originally your buttons are mapped as so
Button; Play, Mapping; play
Button; Shift, Mapping; shift

So to get the result you want you need to change the play mapping to

shift ? reverse : play
Query the shift variable value = 1, if true reverse, if false play.

Vdj has changed now that if you press shift + play, it will create a new mapping entry called shiftplay.
It makes life easier for sure, but when i started mapping my gear it wasn't available, the old way still works today and I'm going to go thru how i mapped back then.


Ok let's see something practical...

In the empire of dirt here, I've a run of the mill mid range (old) controller but this isn't about that.
I've also got launchpad2 (it's about this,)
My goto pad is one I developed myself.
The bottom 8*4 pads call effects in various ways

The first row has fx for slot 1
The 2nd row for slot 2
3rd for slot 3
The last row of 8 just toggle fx, no slot number needed,

I generally just toggle the fx on and send it to a slot with something like this, slot number, fx name.
effect_active 2 "flanger"

So row 1 button 1
I put the hi pass filter
effect_active 1 "filter hp"
Row 1 button 2
I put the low pass filter
effect active 1 "filter lp"

I filled a lot of buttons with fx until i spotted a problem.
I'd like to use both the hp and lp filters at the same time.
I could move to a different row but i would be changing the mapping all the time when I'd notice I like this fx with another fx, and that gets tricky to remember whats what.
So i decided I'll keep the originals and add a copy of lp filter to another row.
effect_active 2 "filter lp"

But now I've a new problem, what if I had lp filter on and active on slot 1 and I want to use hp filter on slot 1 and move the lp filter on slot 2.
If i just use effect_active 2 "filter lp"
Then sure the fx goes to the slot but it gets turned off.
I need to use effect_select_multi
I need to change my mapping.. ok I'll use shift+row2button1 to do it

So my mapping now looks like this

shift ? effect_select_multi 2 "filter lp" : effect_active 2 "filter lp"

Very good with normal press i can get the fx on slot and toggle on/off, with shift pressed i can get fx on slot without toggling.

Thats it is it? Oh no, that hasn't covered every eventuality, i can send the fx to slot, and send to slot and toggle, what about if i had the fx running on slot and used another fx on that slot, thus kicking the lp filter off the slot? How do i turn it off?
If i normal press the fx will turn off sure but then that will kick out whatever else was on slot at the time, I'd be making work for myself.

For normal press I need to query if the fx is running, if running turn the fx off : if not running send to slot and turn the fx on.
And that looks like this

shift ? effect_select_multi 2 "filter lp" : effect_active "filter lp" on ? effect_active "filter lp" off : effect_active 2 "filter lp" on

The on & off 's aren't needed (toggling would be fine for the switching and if ommited from a query vdj assumes you are asking "is it on?" i just added them to help you read it
Is shift pressed? Yes, so we want the fx back on slot without toggling the fx or turning the other fx on slot off : not shifted, is the fx active ? (We don't use a slot number, it may be on this slot or another slot or no slot, all we want to do is to switch it off)
Yes its active, turn it off : no its not active, bring it to slot and turn it on.

This is reasonable strong scripting, cover all possibilities and it will work reliably every time.

Now this was all organic, the problem as i see it I'm wasting buttons, when i start from scratch I'll have a better system that uses variables and then every button will control a different fx and I'll be able to send them to any slot, but that's another lesson.

(might link the fb crowd in now)
 

Posted Thu 07 Jun 18 @ 4:04 am
RanikiPRO InfinityMember since 2018
Hi Locodog,

Thanks for a really interesting and useful thread!

Quick question on the new 'Shift' function... with the old scripting I think a distinction was made between a global '$shift' variable and a deck specific 'shift'..... is it possible to make this distinction with the new system or is it always deck specific?

Cheers
 

Posted Thu 07 Jun 18 @ 11:21 am
locodogPRO InfinityModeratorMember since 2013
As far as i know shift is global but linked to the hardware, like if i pressed shift on my launchpad and a button on my controller, vdj would see both events but wouldn't link them, i can remember there is one class of hardware that the shift is truly global i think it is dashboards but this is configured in the definition file.

Again local shift per device side is sonething set by the def file and i think its not used anymore

I think you could have shift per side with device_side and local variables but it would be a step backwards in my opinion, unless you have an interesting reason why you want local shift, then I'm all ears

Then there's hardware shift but that reconfigures the hardware to send completely different midi messages
 

Posted Thu 07 Jun 18 @ 11:37 am
locodogPRO InfinityModeratorMember since 2013
Moving on through fx...
If you've read the previous lessons this first bit should be easy.

effect_button
Has 3 possible params
1st optional param, Slot number
Alternate 1st, optional, "FxName" in quotes
2nd optional, Button number
3rd optional On/Off

'effect_button 1 2' button 2 on slot 1.
'effect_button 2' button 2 on slot 1,
if vdj doesn't see a 1st then it assumes slot 1

if vdj doesn't see a 1st & 2nd then it assumes slot 1 button 1

'effect_button "echo" on' 1st button of the echo fx to on
if vdj doesn't see a 2nd then it assumes button 1

Effect_slider is very similar, but before i repeat myself, lets briefly go thru how vdj script gets values from hardware sliders.

You turn a hardware slider, and it sends a midinote and a value, the first thing that happen inside vdj is it runs this thru a definition file,

The def file first gives a name to a midinote, thats the name you see in mapping, it then translates the value sent to a vdj value, old midi sends values from 0 to 127 (7 bits precision for binary fans), and vdj usually scales these from 0 to 1.0.

So after that is done under the hood it passes the name and translated value to the mapper file,
We've skinmed def files (there be dragons here) and we're back to mappers, the bit we're used to.

So we've turned a dial to, lets say filter dial to half, the info that gets to the mapper is, something called filter has been set to half, then we need a script to actually instruct vdj what to do.

The dial may be called filter but until the mapper script says that controls vdjs filter it does nothing.

And as you can see from a filter dial mapping, it just says filter.... where does the the value come in?

Well what happens is any script that accepts value parameters has the value stuck on the end of it.

So stupid example here lets say you map the dial named filter to "filter 75%" (stupid, a waste of a dial)
Using our hardware example (filter dial, half way)

Vdj sees "filter 75% 50%" (hardware value stuck on the end)
Since the filter script only accepts one param, the 50% doesn't mean anything so vdj ignores it.

....going slightly off track here, but remember the hardware value, (known as the implicit value) is always tacked on the end of the script, if it makes sense in the script it's used, if it doesn't it's ignored.

Back on track effect_slider, very much like button above

effect_slider
1st optional slot number
Alternate 1st optional "fx name"
2nd option slider number
3rd optional value.

Values can be written in a few ways the 2 most common are % (from 0 to 100 & you can also have 1.5%)
The other common way is between 0.0 and 1, there are other ways but i dont think many people use midi 0-127 or the other one 0-4095.

Values can be definitive, " filter 1.5%" will set the filter @ 1.5%
Or thet can be relative " filter -1.5%" will move down 1.5% from where the it was before.

Why would you want a slider to be given a preset value?
Well as you know, when using effects you generally start the fx with subtlety, then as you're building up to whatever you can push it to extremes, this works some of the time. But what happen after you have turned the fx off and want to use it again? The settings are still at the extremes.

So let's use script to save us some work
Lets say you like to start echo with a strength at 20%

effect_active 1 "echo" & effect_slider 1 20%
Works ok for switching the fx on, but on the second press to turn it off it will mess with the slider again and that might ruin the trailing echo tail you had set up.
Let's think we need to use queries to establish are we turning the fx on or off, so only when we switch on do we want to set the strength.

Take a second, by now you should be able to say the script needed in your head.

effect_active "echo" off ? effect_active 1 "echo" on & effect_slider 1 20% : effect_active "echo" off

Ok that is probably a little different to what you thought, firstly i queried is echo off, i did this because our monkey brains like to have things ordered "turn on first turn off second"
So querying off first is how we see problems in the real world.
Next i didn't use the fx name to set the slider, well we know the echo is on slot 1 we just put it there, so no need.
3rd thing to turn the fx off i used the fx name not the slot, why?
Well as we've seen in the previous lesson, it may be on slot or another or none, while using the slot number will work if you keep everything simple, forever. As your mapping grows so will the complexity. We just want echo off and no matter what changes happen in the future, if echo is on, this button will turn it off.

Gone on for too long on this one, next post is something practical with why you'd choose fx with no slots, and why i love & how i use the loop roll fx.
 

Posted Sat 09 Jun 18 @ 6:14 pm
locodogPRO InfinityModeratorMember since 2013
Ok why i love the loop roll plugin,

Back in the v7 days i used to use the loop based loop roll to mash build ups, what I'd do is mash the build up and when the track came to the crash I'd use a goto -8 to jump back 8 beats.

So anywho, i put a wish out there to have two types of loops, standard loops for... well standard loops, and loop roll inside a standard loop to keep it's own time.

And what do you know with v8 the loop roll plugin was born.

So you can have a standard loop and you can mash the beats with the loop roll.

Now looproll fx and the slicer are perfect examples of why you would call an fx without a slot, they're button based,
If you have buttons to spare you could just say this button only does one thing. And no slot is needed.

If you dont have that many buttons to spare you may wish to have your buttons run double duty (in one circumstance do one thing, in another do something else) like run loop roll fx or slicer

Lets see that script, and since you don't really need to see the fx on slot, (but need it on slot to query to get double duty) let's use slot 4, yes slot 4 you can't see it (on most skins, fruit's you can) but you can use it.

Ok we'll have 8 buttons double duty, if slicer in on slot 4 then buttons act on the slicer fx, if loop roll is on slot ,4 act on the loop roll fx.
And of course we need a button to put the fx on slot, that can be double duty too.

*edit; tiny note, there's a long standing bug with the slicer & loop_roll fx, if one is active you can't have the other (all on one deck)
Not to worry a simple fix with script, just turn the other one off*

fx on slot
effect_select 4 "slicer" ? effect_select 4 "loop roll" : effect_select 4 "slicer"
Is slicer on slot 4 ? Yes put loop roll on slot, No put slicer on slot.
Notice we didn't turn the fx on, the 8 buttons do this for us automatically.

Since we've seen how to make the fx select button double duty making the 8 buttons double duty is easy

effect_select 4 "slicer" ? effect_button "slicer" 1 : effect_button "loop roll" 1

...wait a minute, why am i calling specific fx buttons when i dont need to? Good point.
effect_button 4 1 would work just fine,
It would but I'm not a fan of loop roll 1/32th (too harsh for me and i like speedcore) so i would have the first button do 1/16th
effect_select 4 "slicer" ? effect_button "slicer" 1 : effect_button "loop roll" 2.

Quick word about slicer and loop roll buttons, I've used the old script (effect_button "" #) before pads were invented that was the way.
Since pads vdj created a few new verbs have been made.
Slicer [button number]
&
Loop_roll [button value].
Slightly quicker to write for us but they mean the same as old script.
There's more new verbs like this I'll mention them as we come across them.

Right i rarely use the slicer and when i use it i use the pad page, but i do use 4 of the loop roll fx buttons lots. So i have 4 buttons on my launchpad, always there and ready to go.

the bit i think nobody else does


The thing about the loop roll buttons is they are fx on while_pressed (non latching) i dont want that, i want latching (press on press off)

To have latching (lets say loop_roll 0.25 [1/4 beat]) i need to first query if fx is off, if true, turn the fx on & call the 0.25 button. If the fx off query is false (therefore fx on) query the 0.25 button, if true that is my second press of this button and i want the fx off , if not true (maybe 0.5 button was selected) call the 0.25 button.

The script looks like this
effect_active "loop_roll" off ? effect_active "loop_roll" & loop_roll 0.25 : loop_roll 0.25 ? effect_active "slicer" off : loop_roll 0.25

*edit remembering the bug we mentioned earlier we start this script with " effect_active 'slicer' off & " *

I've 4 buttons like this (0.25, 0.5, 0.75, 1) and they're great for mashing up, inside a loop or outside.
Notice i don't use a slot, my buttons just do one thing and i don't need to see anything on screen, so no slot needed.

New verbs
with this there are 3 ways this script could be made to work, the way above with "loop_roll (button value)" the old way (that i used was to query and set the loop roll slider [eugh not fun]
There's also "effect_beats"
All the same difference, the first way is the quickest to type.
Beats example
effect_active "loop_roll" off ? effect_active "loop_roll" & effect_beats "loop_roll" 0.25 : effect_beats "loop_roll" 0.25 ? effect_active "slicer" off : effect_beats "loop_roll" 0.25

* remember the bug fix *

Think of any beats slider on an fx like it has notches in it like turntable pitch 0%
effect_beats can accept either a value like above or a +or- value to move so many notches,
So if we were set to 1/8, effect_beats "loop_roll" +2 would move 2 notches to 1/2.

Enough for this one, not sure where I'm going next.
 

Posted Wed 13 Jun 18 @ 5:06 pm
wonder if you would mind covering this in your next post. I have three buttons on which i can assign three different effects, but i would like the knobs to control the parameters of which ever effect is active at the time.



So if i activate the second effect, i want the three knobs to control the parameters of that active effect.

effect_active 1 ? effect_slider 1 1 : effect_active 2 ? : effect_slider 1 2 : effect_active 3 ? : etc etc etc Can I use the term effect_slider 1 1 to indicate that I want the knob to control the first parameter of the effect in slot 1

How would I go about writing such a script?
 

Posted Fri 15 Jun 18 @ 10:20 pm
locodogPRO InfinityModeratorMember since 2013
Sure but let me ask you...

You are correct in your assertion but the question is what happens when two or more effects are on and active on slots? What about if nothing is active?
How do you pick?

Actually 2nd question, what controller are you using? I can look at the mapper myself.
 

Posted Sat 16 Jun 18 @ 2:19 am
RanikiPRO InfinityMember since 2018
Hi Locodog,

Thanks for the reply to my 'shift' query...

I've got some further questions on this but I'll post them as a separate thread so as not to use up bandwidth on this thread....
 

Posted Sat 16 Jun 18 @ 11:06 am
locodog wrote :
Sure but let me ask you...

You are correct in your assertion but the question is what happens when two or more effects are on and active on slots? What about if nothing is active?
How do you pick?

Actually 2nd question, what controller are you using? I can look at the mapper myself.


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

sorry I took so long to reply

I am using the Vestax VCI 400.

I actually did not think of combining effects as i anticipated that i would be using one effect at a time and the knobs would have been used only for the effect parameters for now.
 

Posted Mon 02 Jul 18 @ 3:17 am
locodogPRO InfinityModeratorMember since 2013
wrote :

wonder if you would mind covering this in your next post. I have three buttons on which i can assign three different effects, but i would like the knobs to control the parameters of which ever effect is active at the time.

So if i activate the second effect, i want the three knobs to control the parameters of that active effect.

effect_active 1 ? effect_slider 1 1 : effect_active 2 ? : effect_slider 1 2 : effect_active 3 ? : etc etc etc Can I use the term effect_slider 1 1 to indicate that I want the knob to control the first parameter of the effect in slot 1

How would I go about writing such a script?


VCI 400 looked a solid controller years ago when I was looking, it must be soild if it's still going today.

Ok looking at it, this is for dial 1
first you query if the slot is active, if yes effect the slider as you have said, if false query the second slot, if yes do the slider , if false query the third slot and if true do the slider,

effect_active 1 ? effect_slider 1 1 : effect_active 2 ? effect_slider 2 1 : effect_active 3 ? effect_slider 3 1 : nothing

the problem is you have no control of fx dial while they are switched off. so what I would do is use shift+dial to set a variable so vdj can control the dials on the slot of your choice even if all slots are off so your first dial will look like this

shift ? set "@slotVar" 1 : effect_active 1 ? effect_slider 1 1 : effect_active 2 ? effect_slider 2 1 : effect_active 3 ? effect_slider 3 1 : var_equal "@slotVar" 1 ? effect_slider 1 1 : var_equal "@slotVar" 2 ? effect_slider 2 1 : var_equal "@slotVar" 3 ? effect_slider 3 1 : nothing

so if no slot is active a quick press of shift and twist dial 1 and slot 1 makes the variable = 1, it tests if any slot is active, if none are then the query
var_equal "@slotVar" 1 ? is true so control slot 1

your other 2 dials start
shift ? set "@slotVar" 2
shift ? set "@slotVar" 3
of course changing the 2nd param (slider number) of effect_slider [slot#] [slider#]

we use persistant variable (the name starts with @) so when you close vdj the var is remembered for next session, and because of the order we wrote the script, active slots always have priority.

Now you have control but no visual feedback, but we can fix that with script as well, what skin do you use?
 

Posted Mon 02 Jul 18 @ 4:04 am
locodogPRO InfinityModeratorMember since 2013
Had a quick tidy up of a few posts, I think the next one will be the dark art of param_cast, param_multiply, param_add and how to do something useful with them.

It'll take a while to write up and I'll help supertess in between, and anyone else who has an idea or wants a concept explaining.
BUT don't go empty handed, here's a script I wish I had known about a long time ago (would have saved me many thousand mouse miles during mapping)

settings "controllers"

stick that on a keyboard button, and save yourself a few seconds for every mapping you do. ;-)
 

Posted Tue 03 Jul 18 @ 2:02 am
locodog wrote :
[quote= ]


Now you have control but no visual feedback, but we can fix that with script as well, what skin do you use?


Thanks so much for that help. Away from my laptop at the moment but will try it out as soon as I get back home and let you know how it went. I use the silver sleek 3 skin
 

Posted Thu 05 Jul 18 @ 10:37 pm
locodogPRO InfinityModeratorMember since 2013
Silversleak3, too many changes needed to work out as a tut, I'll give you the basics.
 

Posted Fri 06 Jul 18 @ 11:19 am
I assumed that the execution of a non-query keyword would return false. That was expected, but in the following, set 'var1' 1 is not executed which was not expected. set 'var3' 3 is executed though.

set 'var1' 1 ? set 'var2' 2 : set 'var3' 3

In order to get set 'var1' 1 to execute you need to do:

set 'var1' 1 & false ? set 'var2' 2 : set 'var3' 3
...or
set 'var1' 1 & true ? set 'var2' 2 : set 'var3' 3
...or
set 'var1' 1

I thought that was strange. In the above posts, I was implying that it is important to know what verbs are queries and what ones are not. Probably fairly easy to make a mistake with that and then you have some odd behavior to boot. The documentation tells you above some queries, but not for others so it leaves you guessing.

As a side note, I was playing with the script engine from C++ and was tracing thru it some and noticed that newlines are ok when sent from C++. But when newlines are used in the script text on a skin, they do not appear to work so I assume that when the text sent from the skin, the text is truncated at the newline. It is still there for display though.

Adion wrote :
In the first one, you are querying set instead of executing it. In that case it's similar to checking the value of 'var1' and comparing it to 1.

In the second and third one, it should be read as
set 'var1' 1 & (false ? set 'var2' 2 : set 'var3' 3)
Which you could more simply just write as
set 'var1' 1 & set 'var3' 3

(Regardless, if you would expect the first one to set var1, I'm not sure what you would expect the question mark to do in that case, since the var would always be set to what you asked it to be set to)

Edit: The reason why set also works as a query is so that it would also work on buttons for example without having to write a separate query for lighting up the button.


Don Moir wrote :
Ok that explains that then but then you can see the confusion of it I think. So is it such that everything can be treated as a query?

in C++, I might do something like:

int var1;
int var2 = 2;
if (var1 = var2) // assignment and test
....do something;


locodog wrote :
New lines and indents are fine in pad/mappers editor. Have been for at least 6 months probably longer.


Don Moir wrote :
Well I put a newline into Phatoms collapse script on one of the custom pad buttons and it no longer worked. The same script with the newlines did work when sent from C++ so go figure. Extraneous spaces have always worked I believe.

edit: Ah I see, it depends on where you put the newline. If before a ? then it appears not to work. If after the ? then it works. So inconsistency?

So I double checked, and the script that did not work with just one newline from the skin, does work when sent form C++. Originally I sent the complex script with a newline before every ? and : and that also worked when sent from C++.. But that script also does not work when put on a skin button.


Don Moir wrote :


Adion wrote :
Edit: The reason why set also works as a query is so that it would also work on buttons for example without having to write a separate query for lighting up the button.


When I was first testing this, I was using effect_string instead of set. Since it was my effect_string declare, I expected it to fire my code but it does not. No telling what the query value of it is except false.

edit: Some of these things just come up when I am testing for doing other things. When I tested newlines in script long ago, it did not work. But when I am tracing thru the SendCommand last night, I see that newlines are handled. So I try that in C++ and it worked. Thought to try it from a skin button and ran into problems. Same sort of thing with queries but in that case also a user needs consistency. For my goal it is something different, but still, I or we need to know :)


Adion wrote :
When queried, 'effect_string 1 "test"' should be true if the string is equal to "test"


Don Moir wrote :
Ok... since the declares don't have an option to handle queries, I guess that makes sense. In the doc it says:

Commands can be used either as actions or as queries, depending on the context.

Some commands can return a boolean (true or false) or a value, depending on the parameters:
- "crossfader" will return the value (between 0.0 and 1.0) if used in a query. Will also return true if its value is greater than 0.5 and false if smaller.
- "crossfader 42%" will return true if the crossfader is at 42%, and false otherwise.
Some other commands can return a string or a number, depending on the verb. (usually verbs starting with get_ )
- "get_time_ms" will return the time of the loaded track in ms as an integer
- "get_artist" will return the Artist of the loaded track as text


...and some other commands do something else I guess.

That seems to say every keyword can be a query or an action and it just depends on the keyword as to what the query result (and parameter) actually is. Maybe every keyword should be documented as to what the query of it means. I am not sure what the query value of get_ms would be for example but from your explanation it might be get_ms '1000' and then be true if equal to '1000'. Useless test I know but just for clarification.

If I use something starting with get_ it may not mean get and it might mean just test the value of whatever.


Adion wrote :
typically the boolean query 'action value' is only implemented if that is also a valid action for setting something to that value, for the reason mentioned above.
get_time_ms can not be used as an action to set the time, so it only returns the time as advertised.
For queries involving these, you can of course use param_equal etc... to compare them and use them in boolean queries.


Don Moir wrote :
Thanks. so get_effect_string when used as query does not get the effect string... gotcha :) and is actually implemented as test_effect_string


Adion wrote :
Typically, you use get_effect_string to get the actual string value, which it will of course do, and not to check if it has a specific value.
effect_string on the other hand would be used to set the string to a specific value "effect_string value", and can therefore also be used in a query to check for this specific value.

In this specific case, get_effect_string is just a synonym for effect_string, so both will actually work. get_ for many actions is only there because of compatibility with v7.
For new actions that make sense both as get_ and set_ just a single one will usually be added to do both query and set.


Don Moir wrote :
Yeah I saw that get_effect_string is just a synonym for effect_string and realizing now why you are probably wanting to get rid of the get. You know that in normal programming things tend not to be seen as ambiguous and in general considered to be bad. Meaning in most languages, if you call a function, no matter how it is used in a statement, the function is called.

I realize you are trying to keep script simple, but simple only works to a point before the simple becomes complex. I have been thru this before with much discussion in another world. Feeling like we are getting off subject in loco's thread to a degree now though. Thanks for the info guys.
 

Posted Sun 15 Jul 18 @ 5:18 pm
3%