in lua script in the Watchmaker app I can set the rotation for an object in a way that amounts to something like this:
if hour = 1 then xx deg
if hour = 2 then yy deg … and so on
how is this accomplished with expressions in facer?
Much thanks!
in lua script in the Watchmaker app I can set the rotation for an object in a way that amounts to something like this:
if hour = 1 then xx deg
if hour = 2 then yy deg … and so on
how is this accomplished with expressions in facer?
Much thanks!
Facer Documentation may help: Conditionals – How can we help?
You can use something like $#DH#==(Your Hour 0-23)?(Value If True): (Value If False)$
Hope that works
That seems simple enough, can I stack those so it’s not just a single true/false but multiple? And how do I do that?
Example would be if I wanted a fixed rotational position value assigned to each hour.
$#DH#==( Your Hour 0-23 )?( Value If True ): ( Value If False )$
And
$#DH#==( Your Hour 0-23 )?( Value If True ): ( Value If False )$
And
$#DH#==( Your Hour 0-23 )?( Value If True ): ( Value If False )$
…and so on…
What’s the proper way to express “and” for multiple expressions this way?
Thanks for the help!
could you elaborate more on what you are trying to accomplish? I feel there is a better solution to what you might try to do than a bunch of conditions…
To achieve your latest example you can do something that is both undocumented on Facer and also risky because it seems some watches don’t support it, or perhaps only support it in certain fields/elements… that’s still not clear to me (but obviously something wrong is up with it somewhere because Facer still hasn’t officially documented it):
$hour==1?true:$$hour==2?true:false$
Where default deg
is the output when none of the “stacked” conditions return true. You can repeat that sequence as much as you like:
$hour==1?xx_deg:$$hour==2?yy_deg:$$hour==3?zz_deg:default_deg
Where you would normally add a :
colon and then the “false” output, you add a :$$
colon and 2 dollar signs, and then start a new condition. When you wanna wrap things up, you end the formula the “normal” way, by simply adding a value after a simple :
colon and then end it all with a single $
dollar sign.
Thanks @AllenMiquel I won’t have a chance to mess with this until tonight but I’ll let you know if it’s working for me. What you’re describing sounds like what I’m trying to do.
No problem. Again, undocumented stuff but there’s a lot of examples and similar questions/answers here on the forums that lead to the same kind of formula structure/stack/whatever you wanna call it xD In some of them you might find when someone explained where this thing is safe to use (where as in which field [text, rotation, etc]), though not even sure to what extent even that is accurate For the most part, it’s a risk.
I’d say if you’re gonna make something big with this and heavily dependant on it, try to come up with an alternative way to achieve it, and maybe either let the user choose which one to download/use, or keep it in the back pocket for the day someone comes knocking asking why your watch face doesn’t work for them. The alternative way will undoubtedly be more complex, or take more elements, but it’ll at least be safe.
If the degrees you want are evenly distributed it would be a lot easier to do something like (hours * x degrees) to get what you want
I was unable to get the stacked expressions to work in the app. never tried on the watch. But… I’m revisiting a watch I made quite a while ago, and now I see that I’m able to accomplish the needed rotation without anything to crazy. I’m also beginning to get a feel for how to adapt lua scrip to Facer expressions. So while I’m not able to use your suggestion exactly, it was still helpful because it was still insightful into how to work with expressions and got me problem solving in the right direction. so thanks @AllenMiquel and @ThaMattie !
though along the same lines… what if I want opacity set to 100 for hours 1, 4, 7, 10 but 0 for the rest?
You can use modulus (which is usualy implemented as remainder, not really modulus, but ok):
$(#Dh#%3)=1?100:0$
So 3 is your interval, and 1 is the remainder you need
@ThaMattie Thanks! That works perfectly
I’m more of a graphics guy than a coder, but I’m usually pretty good at adapting script I’ve seen or used before for a different purpose. But I’m totally not used to where and when for all the #,$,:, and parentheses in facer. It doesn’t help that apparently some things work as intended in the creator but then not in the watch preview in the phone app. But I’m learning that usually a parentheses or two will fix that!
np, make sure to show of your work when it’s done!