ZBrushCentral

Zscript Ternary operator

Does ZScript have a ternary (contitional) operator?

No. I asked this two years ago! D’oh!

zscript ternary ? no! : d’oh!

:slight_smile:

Well if fails else I’ll ask again next year

And yes Marcus, I appreciate that was the best answer ever!

Any hoops I did manage to get the Lazy Mouse toggle to work as a macro in the end:
It tells you the status of the Lazy Mouse (I find it difficult to work out at low settings)

// lazy Mouse switch
// 21 March 2019
IButton, “lazy Mouse”, “Toggle lazy Mouse”,
VarDef, lazyState, ""]
VarDef, lazyBool, 0]
// is it switched on?
VarSet,lazy,IGet,Stroke:LazyMouse]]
If, IGet, Stroke:lazy Mouse],
VarSet, lazyState,“OFF”]

VarSet, lazyBool, 0]

// if it’s ON, turn it OFF

IUnPress, Stroke:lazy Mouse]

,// else

VarSet,lazyState,“ON”]

VarSet, lazyBool, 1]

// if it’s OFF, switch it ON

// press lazy mouse

IPress, Stroke:lazy Mouse]

]
// Notebar
NoteBar, StrMerge, "Lazy Mouse is ", lazyState], lazyBool]
// [Note,[StrMerge, "Lazy Mouse is ", "
", lazyState], 1, 1]

]// End of ZScript

You can simplify the code like this:

IButton, “lazy Mouse”, “Toggle lazy Mouse”,
VarSet, lazyState, “OFF”]
VarSet, lazyBool, 0]
IToggle,Stroke:lazy Mouse]
If, IGet, Stroke:lazy Mouse],
VarSet, lazyState,“ON”]
VarSet, lazyBool, 1]
]
// Notebar
NoteBar, StrMerge, "lazy Mouse is ", lazyState], lazyBool]
]// End of ZScript

(I always forget about IToggle!)