Notifications
Clear all

[Closed] repeatedly calling a function until checkbox unchecked

This is a terrible ‘nooby type’ question I know but I’d like the following function to loop so that it plays again until a ‘loop’ checkbox is turned off…
:


 
 
fn replayMove = 
(
 
	p = 1;
 
	 (
				 for t = 1 to tracker.count do 
 
			 ( struct capture_struct (time, pos);
 
					diff = (tracker[t].time - tracker[p].time)
 
				 if diff >= 1000/framerate then 
-- 
				 (
  --optional movement of slider	  slidertime = slidertime + 1;
		struct capture_struct (time, pos);
	 $.pos = tracker[t].pos ;
		 p = p +1;
				 )
-- 
 
		 )
 
	 );
	slidertime = startframe[1]; $.pos = posObjectStart[1];
	 t =1;p =1
 
on loop changed [state]( http://forums.cgsociety.org/#)  do (replayMove())
 
 
);

Only I get into dependency loop problems so it doesnt work as expected.
Is there a simple appoach using while…do…or something of that nature?

6 Replies

Simplest suggestion… Can you just use the loop on/off control in the time configuration dialog…

timeConfiguration.playbackLoop = false

If you’re moving the time-slider in maxscript I’d use a Timer set to an interval of 1 frame and check to see if the checkbox is ticked.

thanks for that bud…but I don’t really want to use the slider as this interrupts the thread…the slider movement is optional…the thing that moves the object around is $.pos…this is what i want to loop…

I’d suggest the use of a timer which calls the function on tick.
Something like that :


  timer myTimer tick:1000  

  on myTimer tick do (
      if myCheckBoxState do ( 
          myFunction()
      )
   )


I’m not sure of “tick” property though, could be some other name, i don’t usually use timers.
Also, so you won’t have lagging in your command such as function – nothing – tick – function -nothing… you might call your function in a loop. Running a performance tets to check how much iterations you need to perform so it’ll run for a second
This might also be a terrible solution, so please MXS pros feel free to prove me wrong !

Can you use a timer?

Yes I can use a timer.

Nice, need help?