Advanced Conditions: Calculations with variables

Hi there,

first off, I love BTT's functionality, especially with advanced conditions!

I have a question regarding those advanced conditions though:
Is there a way to create conditions containing simple calculations with variables? As an example I was thinking about something like this:

rightmost_touch_x_percent - leftmost_touch_x_percent >= 30
AND condition fingers_touching_trackpad == 2

This could be true if I use my index and little finger to touch the trackpad instead of index and middle finger.

This is just one example. In my opinion this could open up a lot of possibilities for interesting advanced conditions.

Your help would be much appreciated.

Best regards

Marc

Unfortunately the conditions editor (a standard macOS component) doesn't allow this.
However if you need such conditions I'd recommend to use the "Real Java Script" action. E.g.

(async ()=> {
const rightMostTouch = await callBTT('get_number_variable', {variable_name:'rightmost_touch_x_percent'} };
const leftMostTouch = await callBTT('get_number_variable', {variable_name:'lefttmost_touch_x_percent'} };
const touching = await callBTT('get_number_variable', {variable_name:'fingers_touching_trackpad'} };

if(rightMostTouch - leftMostTouch >= 30 && touching == 2) {
// named triggers can be configured in the "Automations, Named & Other Triggers" section
let result = await callBTT('trigger_named', {trigger_name: 'Action5'});
}

returnToBTT('finished');
})();

Thanks a lot for your quick reply!

I am a bit intimidated by the script but I will try to play around with it.

Best regards

Marc

Most of it is just getting the variable you need, and then checking your condition. If the condition is true, the script will trigger a named trigger which in this example is called "action5".

Much appreciated, thanks!

I am really sorry to bother you again, but after playing around a bit I feel pretty stuck:
It seems as if I can not get variables from the advanced conditions like finger_touching_trackpad or left_mouse_down with the get_number_variable function.

A simple example:

(async ()=> {

let result = await callBTT('get_number_variable', {variable_name:'fingers_touching_trackpad'});

returnToBTT(result);

})();

This simply gives me an "undefined".

It is very well possible that I am missing something or that I am getting something wrong here since this is pretty much my first time using Java Script.

Any advice would again be much appreciated.

Best regards

Marc

Sorry, I forgot to mention that this requires the latest alpha version as there has been a bug retrieving number variables, which has been fixed recently.

Thanks for the clarification. Outstanding support!

Best regards

Marc