Notifications
Clear all

[Closed] wrestling with custom atts

Where’s PEN? Whenever I see a custom attributes question Paul is always the first reponder, maybe he’s on vacation?

@dmak – Whoa! Thank you so much, man!

@moondoggie – I can easily imagine he took one look at my posted code and walked away, shaking his head.

Say, Dan, I tried your code but I’m not having any luck with it…

(
ca = attributes New
(
parameters main rollout:params
(clutch type:#boolean ui:btn_clutch default:false)
 
rollout params "Wire Toggle"
(
button btn_clutch "Clutch Button"
 
on btn_clutch pressed do
(
clutch = not clutch
print clutch
)
)
)
rollout wTest "Watcher"
(
button btn "Actuate"
 
on btn pressed do
(
b = box name:"testbox"
custAttributes.add b ca
b.clutch.controller = boolean_float()
p = point name:"Watcher"
fs = float_script()
fs.addTarget "Watcher" b.clutch.controller
p.axistripod.controller = fs
p.axistripod.controller.script = "if (Watcher == true) then $testbox.rotation.x = 45 else $testbox.rotation.x = 0"
)
)
createDialog wTest 200 50
)

Am I missing something here? (I’m trying rotation rather than paramWiring to keep it as simple as possible until I understand it). Thanks.

If you print Watcher in the first line of your script controller you’ll see in the maxscript listener it actually returns 1.0 or 0.0 as the boolean float controller resutls in a numeric value. Change your axistripod code to test Watcher against a numeric value (1|0) and it should work.

I think that sorted it out. Thanks, Dan.

 PEN

Yes I have been hiding, Does this thread still need answers?

Hey, PEN, thanks for the response. I seem to vaguely in control of this puppy for the moment.

Here’s what I finally came up with…

(
ca = attributes predecessor
(
 parameters main rollout:params
 (
  pred type:#node
  clutch type:#integer ui:btn_clutch default:1
 )
 rollout params "Predecessor Test"
 (
  button btn_clutch "Clutch Button"
  
  on btn_clutch pressed do
  (
   if clutch == 1 then clutch = 0 else clutch = 1
  )
 )
)
rollout predtest "Test Pred attribute"
 (
  button btn_init "First Box"
  button btn_next "Next Box"
  local p, i=50, holder, fs
  
  on btn_init pressed do
  (
   b = box()
   custAttributes.add b ca
   print b.clutch
   p = b
   
  )
  on btn_next pressed do
  (
   b = box pos:[i,0,0] 
   custAttributes.add b ca
   b.pred = p
   holder = point()
   holder.parent = b
   fs = float_script()
   holder.position.x_position.controller = fs
   fs.addNode "cube" b
   fs.script = "with animate off (if cube.clutch == 1 then cube.pred.pos.y = 50 else cube.pred.pos.y = 0)"
   i += 50
   p = b
  )
 )
createDialog predtest 200 60
)

Something of a variation on your solution, Dan, but this does exactly what I’m after. Thank you to all.

Page 2 / 2