Notifications
Clear all

[Closed] create slider – undeclared variable?

Hey, I’m working on a script to help with a rigging task. I’m having trouble with part of it.

I’m trying to create a slider under an EmptyModifier (attribute holder) where the slider’s range is set by a variable ‘i’ defined earlier in the script. Here’s what I’ve got:

i = 3   --this would normally come from an earlier part of the script
MoveHelper = point()
em = EmptyModifier()
addModifier MoveHelper em

--Add controls to the attribute holder
ca=attributes SwitchControls
	(
	parameters param rollout:switchRl
		(
		slswitch type:#integer ui:switchSl
		)
	rollout switchRl "Switch - Free:Attached"
		(
		slider switchSl "Free          -         Attached" range:[0,i,0] fieldWidth:160 ticks:i
		)
	)
custAttributes.add MoveHelper.modifiers[1] ca

At first this seems to work fine. The attribute holder and slider are created correctly and it has the right range values. The problem comes when I save the scene with my new slider, close max, and reopen the scene. The ‘i’ variable is no longer defined and the file opens with an error:

–compile error: Undeclared variable: i
– In line: spinner switchSp “” range:[0,i,

My question is: why is max needing the i variable again? shouldn’t the slider already be created and stored in the attribute holder? Is there another way to create a slider that wouldn’t have this problem?

I’m still pretty new to maxScript. Any help would be awesome!
Thanks!

  • Sean