Switch Block Question
Half Life
Posts: 479
I am working on a script and I want to read the base color of the current material and have that output a result matching the RGBA array. It currently looks like this:
var oMat = Scene.getPrimarySelection().getObject().getCurrentShape().getMaterial(0); var oEmissionColor = oMat.getBaseColor();switch(oEmissionColor){case [0,1,0,1]:print("Green")break;case [0.0477758,0,0.21952,1]:print("Purple")break;case [1,1,0,1]:print("Yellow")break;case [1,0,0,1]:print("Red")break;case [1,0.21952,0,1]:print("Orange")break;case [0,0.21952,1,1]:print("Blue")break;default:print("this doesn't work")break;}
Everything seems to be fine but the array matches the case array (I checked via print) and the script does not pick it up. Is it just that cases cannot be arrays?
Post edited by Half Life on
Comments
For anybody else who comes across this issue here is my solution:
Rob does add: