Can you convert a string to a Control UI script?
Posted: 17 Nov 2019 09:50
Currently I have for 'up', 'down', 'left', 'right' recorded gestures. These work in Action boxes which are fed by individual conditions. E.g:
Condition: global_navclick =='left' //global_navclick comes from a widget
Action: Control UI
Script: touchGesture(0,40, newList(100, 1400, 900, 1400));
All ok here!
As the direction conditions and actions run in parallel (or very close sequence), when testing, I kept on triggering the emergency stop. I adjusted the threshold and all worked but I started thinking about efficiency.
I tried replacing the four conditions with one action script, to store the script needed subsequently as text.
Subsequent edit: Spotted that I'd used incorrect syntax (gn='left' rather than gn=='left' etc..)
The next action was a control UI action box.
I've tried in this (unsuccessfully) these alternatives:
but I'm either missing something (most likely) or this can't be done.
Any pointers as to what may make this work would be appreciated. Also many thanks to all the contributors here especially Martin and Desmanto whose answers and archiving have helped my scripts immensely.
Condition: global_navclick =='left' //global_navclick comes from a widget
Action: Control UI
Script: touchGesture(0,40, newList(100, 1400, 900, 1400));
All ok here!
As the direction conditions and actions run in parallel (or very close sequence), when testing, I kept on triggering the emergency stop. I adjusted the threshold and all worked but I started thinking about efficiency.
I tried replacing the four conditions with one action script, to store the script needed subsequently as text.
Code: Select all
gn = global_navclick;
gest="";
if (gn=='left') gest= 'touchGesture(0,40, newList(100, 1400, 900, 1400))';
if (gn=='right') gest= 'touchGesture(0, 40, newList(900, 1400, 100, 1400))';
if (gn=='up') gest= 'touchGesture(0, 40, newList(500,1000,500,700))';
if (gn=='down') gest= 'touchGesture(0, 40, newList(500,700,500,1000))';
The next action was a control UI action box.
I've tried in this (unsuccessfully) these alternatives:
Code: Select all
//gest returns 'gest
eval(gest) //works when first code block correct
//eval({gest})
//{gest}
Any pointers as to what may make this work would be appreciated. Also many thanks to all the contributors here especially Martin and Desmanto whose answers and archiving have helped my scripts immensely.