[Closed] Checkbutton returns to default state
Hi,
I´m a total newcomer to maxscript and I´m starting to build some simple scripts to enhance my current custom bones rig.
For the tail I wanted to add a checkbutton to turn springs on and off and indicate their state.
What I did was this:
parameters globalsP rollout:globalsR
(
springs type:#float ui:springsSl
springsOn type:#boolean ui:springsCh default:true animatable:true
)
--function for springs
Fn springsOn_fn =
(
for i = $PtCtrl_TailFK* do
(
try(
i.pos.controller[#spring].steps=2
)catch()
)
)
Fn springsOff_fn =
(
for i = $PtCtrl_TailFK* do
(
try(
i.pos.controller[#spring].steps=0
)catch()
)
)
rollout globalsR "Global Controls"
(
slider springsSl "0% Springs: 100%" range:[0,100,0] scale:.01 width:130 --across:2
checkButton springsCh "" highLightColor:[0,255,0] width:15 height:15 offset:[70,-25] toolTip:"Turn Springs On or Off."
on springsCh changed state do
if springsCh.checked==false then
springsOff_fn()
else
springsOn_fn()
)
Problem:
The checkbutton seems to do the job, but each time I exit the attribute holder and come back to it, it returns to its default state. So If its checked state is true, it will show up as checked, the next time I select he respective attribute holder, no matter if the springs are on or off.
Since I borrowed most of the code from one of Paul Neale´s Tutorials, I´m not sure what I´m doing wrong here…
This is because scripted plugins only load an instance of the rollout on demand. I don’t know why this isn’t permanent on your tool as I’ve only worked with scripted material plugins and they retain any value I put in parameters. But, if you add the below code you should be right.
checkButton springsCh "" [b]checked:springsOn[/b] highLightColor:[0,255,0] width:15 height:15 offset:[70,-25] toolTip:"Turn Springs On or Off."
--OR
[b]on globalsR open do
(
springsCh.checked = springsOn
--OR springsCh.checked = this.springsOn
)[/b]
[size=2]
[/size]
Haha, I just used this part:
on globalsR open do ( springsCh.checked = springsOn
--OR springsCh.checked = this.springsOn
)