Test whether a light is ambient?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
benroll

Hi All,

Is it possible to test whether a light is of the ambient type?

The problem I have is that when I set an expression for position for an ambient light, I get an expression error.
However I can't test for an ambient light: the position parameter returns [object property] and canSetExpression returns true. I can't find a light_type property in the Scripting Guide and properties like Shadow Darkness, Cone Angle etc. that are all invisible for an ambient light appear as present and expression-settable from a script's point of view. If you set the expression though, it gives an error.

I'm handling it with a try / catch, but I'd prefer to handle it before that. Is there a cunning workaround for this?

Thanks.

Ben.
benroll

Just figured out a way to do it... here it is if it's of any use...

Code: Select all

function getLightType(aLightLayer) {
				
	if(aLightLayer.lightOption) {
		if(!aLightLayer.lightOption("Shadow Darkness").canSetExpression) {
			return("AMBIENT");
		} else if(!aLightLayer.lightOption("Shadow Diffusion").canSetExpression){
			return("PARALLEL");
		} else if(!aLightLayer.lightOption("Cone Angle").canSetExpression) {
			return("POINT");
		} else {
			return("SPOT");
		}
						
	} else {
		return("NOT_A_LIGHT");
	}
}
-Ben.
Post Reply