McMaster
06-12-2003, 01:28 PM
Hi!
Im trying to get into Mel right now, working with Marc`s book. I just tried to make my own little project, but canīt find the mistake. Maybe one of you could help me.
I tried to make a light flicker with a random Value with this script, but I alwas get the error:
// Error: buttonAction($flickerFloatSliderGrp); //
// Error: "$flickerFloatSliderGrp" is an undeclared variable. //
But $flickerFloatSliderGrp to me seems already declared?
The scripts need a scene with a Spotlight named spotLightShape1!
proc make_light_flicker(string $lightToFlicker, float $flickerValue)
{
select -cl;
select $lightToFlicker;
float $current_Intensity = `getAttr ($lightToFlicker + ".intensity")`;
string $Expression_String = $lightToFlicker + ".intensity = " + $current_Intensity + "-(" + $flickerValue + "/2)+ rand( 0, " + $flickerValue + ")";
expression -s $Expression_String; //Create the Expression
}
proc buttonAction (string $floatSliderGrpName)
{
float $flicker = `floatSliderGrp -q -value $floatSliderGrpName`;
make_light_flicker("spotLightShape1", $flicker);
}
global proc LightFlickerUI()
{
string $window_name = `window -title "Window1"
-widthHeight 483 203`;
columnLayout;
frameLayout -collapsable true -label "Flicker" -width 475;
string $flickerFloatSliderGrp = `floatSliderGrp -min 0
-max 0.7
-label "FlickerValue"
-field true
-fieldMinValue -10
-fieldMaxValue 10`;
setParent ..; //Return to ColumnLayout
frameLayout -label "" -width 475;
button -label "Execute" -command "buttonAction($flickerFloatSliderGrp)";
showWindow $window_name;
}
Im trying to get into Mel right now, working with Marc`s book. I just tried to make my own little project, but canīt find the mistake. Maybe one of you could help me.
I tried to make a light flicker with a random Value with this script, but I alwas get the error:
// Error: buttonAction($flickerFloatSliderGrp); //
// Error: "$flickerFloatSliderGrp" is an undeclared variable. //
But $flickerFloatSliderGrp to me seems already declared?
The scripts need a scene with a Spotlight named spotLightShape1!
proc make_light_flicker(string $lightToFlicker, float $flickerValue)
{
select -cl;
select $lightToFlicker;
float $current_Intensity = `getAttr ($lightToFlicker + ".intensity")`;
string $Expression_String = $lightToFlicker + ".intensity = " + $current_Intensity + "-(" + $flickerValue + "/2)+ rand( 0, " + $flickerValue + ")";
expression -s $Expression_String; //Create the Expression
}
proc buttonAction (string $floatSliderGrpName)
{
float $flicker = `floatSliderGrp -q -value $floatSliderGrpName`;
make_light_flicker("spotLightShape1", $flicker);
}
global proc LightFlickerUI()
{
string $window_name = `window -title "Window1"
-widthHeight 483 203`;
columnLayout;
frameLayout -collapsable true -label "Flicker" -width 475;
string $flickerFloatSliderGrp = `floatSliderGrp -min 0
-max 0.7
-label "FlickerValue"
-field true
-fieldMinValue -10
-fieldMaxValue 10`;
setParent ..; //Return to ColumnLayout
frameLayout -label "" -width 475;
button -label "Execute" -command "buttonAction($flickerFloatSliderGrp)";
showWindow $window_name;
}
