Forum Groups
  All forums
    Help & Feedback
      Work in progress
      Finished Art
      Non-Max related

Featured Threads
  inspiration alert!!!
(37 replies)
  Indespensible MaxScripts, Plugins and 3rd Party Tools
(37 replies)
  The allmighty FREE Resources Thread !
(17 replies)
  spam alert!!!
(4886 replies)
  Maxforums member photo gallery index
(114 replies)
  Maxforums Member Tutorials
(89 replies)
  three cheers to maxforums...
(240 replies)
  101 Things you didnt know in Max...
(198 replies)
  A Face tutorial from MDB101 :D
(95 replies) Members Gallery
(516 replies)
(637 replies)
  Dub's Maxscript Tutorial Index
(119 replies)

Maxunderground news unavailable

show user profile  ccampbell
I have what hope is a quick max scripting question.

I am creating a horizontal slider within a rollout and want to select a scecific face and then move it according to the direction i scrub the slider. In that if i scrub left the face always moves positively in the x axis else negatively in the x axis.

Any help would be awesome. I'm very new to max scripting. Ive pasted an example of the code i have now. it works now but when scrubbing in negative integers the face only moves in one direction and same for the positive.
windowfloat = newrolloutfloater "slider test" 250 90
rollout slider "SLIDER"
slider sld1 "Slider Test" pos:[30,2] width:190 height:44 range:[-10,10,0] type:#integer ticks:20
on sld1 buttondown do
$hingebracetrimleft.EditablePoly.SetSelection #Face #{2}
on sld1 changed val do
in coordsys local move $hingebracetrimleft.faces[#{2}] [val,0,0]
)--end rollout
addrollout slider windowfloat rolledup:false

$Entrepreneur = if((Designer + Engineer)*Programmer){Problem Solver};

read 1853 times
6/5/2011 3:42:55 AM (last edit: 6/5/2011 3:43:55 AM)
show user profile  Garp
The logic is a little flawed.

The on changed handler updates val continuously. If you were to print out val in the listener (just add print val in the handler), you'd see 1 2 3 etc when moving to the right. So you first move the face of 1 unit, then of 2 units, then 3, etc. Don't forget that moving is not like setting the position, it's adding to the current position. So by the time you reach 3, you've already added 1+2+3 = 6 units to the starting position.
And that's why it moves toward positive x when you go from 0 to 10, but also when going from 10 to 0. In both cases, val is positive (or null).
Lucky for you you used integers. Had you chosen floats, you'd get a lot more intermediate values!

Try something like this (it moves the selected object(s), not a face):

Btw, this works as well with floating point values.

edit: oh, and check this for more on maxscript ;)

read 1840 times
6/5/2011 5:52:18 AM (last edit: 6/5/2011 6:06:40 AM)
#Maxforums IRC
Open chat window