ZBrushCentral

how to check if answer is yes or no to [[MessageYesNo]

I’m working on a script and I need to check if the answer is yes or no, On the command list it says that YES has a value of 1. But how do use that in an if statement like

[If, (here is what i need to know what to put)=1,
[Note, "Answer is yes]
,
[Note, "Answer is no]
]

I need it because I want something to happen when answer is yes and something else when answer is no

You can set a variable to the return value. I’ve used the MessageYesNoCancel just to show how you can handle more than two values:

[IButton,MessageTest,“Test my message”,
[VarSet,result,[MessageYesNoCancel,“Would you like to proceed?”,“My Plugin”]]
[Loop,1,

[If, result == 0,[Note, “Answer is No”][LoopExit]]

[If, result == 1,[Note, “Answer is Yes”][LoopExit]]

[If, result == -1,[Note, “Operation Cancelled”][LoopExit]]

]
]

The Loop is just a way of making sure no more code is run than necessary.

Thanks man works perfect, is there also a way to change the answers from yes, no and cancel to something else like: keep uvs, delete uvs and edit uvs or some other text you want?

You can do that but you need to use the Note and NoteIButtons like this :

[IButton,TestMessage,“Test my message”,
[VarSet,buttonNo,4]
[NoteIButton,“Keep UVs”,0xff9923]// button #1
[NoteIButton,“Delete UVs”,0xffffff]// button #2
[NoteIButton,“Edit UVs”,0xff9923]// button #3
[NoteIButton,“Cancel”,0xffffff] // button #4

[VarSet,result,[Note,"\Cff9923 Please select option…
",0x282f42,500]]

[If,(result<1)||(result >= buttonNo),//pressing button #4 or pressing Enter/Spacebar

[Note, “You Cancelled”]

[Exit]

]

[Loop,1,

[If, result == 1,//Keep UVs

[Note, “You pressed KEEP UVs”]

[LoopExit]

]

[If, result == 2,//Delete UVs

[Note, “You pressed DELETE UVs”]

[LoopExit]

]

[If, result == 3,//Edit UVs

[Note, “You pressed EDIT UVs”]

[LoopExit]

]

]

]

Thanks once again you’re awesome, learning Zscript is so much fun.

Great! :+1:

I’m sorry for bombing you with questions:eek: but is it possible to get a slider on the message as well. Like set thickness to a certain amount that the user can put in. Also how would you put and undo and redo option on there?

Unfortunately it’s not possible to have a slider. If you need a slider the best way is to have one as part of your plugin interface, such as you’ll find in the Multi Map Exporter, for example. You can have more complex arrangements using NoteIButtons - the online docs has an example with code here:

http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/interfaces/note-interface/