Little help with ListBox


#1

Hi everyone,
So, I want to use a listbox for changing the orientation constraint. (like passe “head follow the neck to head follow the world”). I get it in a too long scrip… but when I take an other object and get back to my controller, my selection as change (but not the constraint).

So here the question, what should i do to “force” the listbox to stay on my last selection?
Here the script I wrote for now…

EP = EmptyModifier()
Ep.name = “Head_Follow”

test = $Suit_H_Head_CONST

ca = attributes HeadFollow
(
parameters param rollout: HeadFollow
(

  'FolHead' type:#float default:0

)

rollout HeadFollow “Head Follow” width:185 height:300
(
listbox ‘FolHead’ “” pos:[15,10] width:130 height:4 items:#(“Neck”, “Shoulders”, “Spine”, “World”) align:#left

on FolHead selected sel do
(
print FolHead.selection

  if FolHead.selection == 1 then 
  (
  	test.rotation.controller.setWeight 1 100
  	test.rotation.controller.setWeight 2 0
  	test.rotation.controller.setWeight 3 0
  	test.rotation.controller.setWeight 4 0
  )
  
  if FolHead.selection == 2 then 
  (
  	test.rotation.controller.setWeight 1 0
  	test.rotation.controller.setWeight 2 100
  	test.rotation.controller.setWeight 3 0
  	test.rotation.controller.setWeight 4 0
  	
  )
  
  if FolHead.selection == 3 then 
  (
  	test.rotation.controller.setWeight 1 0
  	test.rotation.controller.setWeight 2 0
  	test.rotation.controller.setWeight 3 100
  	test.rotation.controller.setWeight 4 0
  	
  )
  
  if FolHead.selection == 4 then 
  (
  	test.rotation.controller.setWeight 1 0
  	test.rotation.controller.setWeight 2 0
  	test.rotation.controller.setWeight 3 0
  	test.rotation.controller.setWeight 4 100
  	
  )

)
)

)
custAttributes.add Ep ca

addmodifier $Suit_C_Head Ep

I know I can shorten the script…