Notifications
Clear all
[Closed] Run function every nth sec?
Jun 05, 2014 9:33 pm
Is there any simple/compact way to do a loop that runs a function every nth sec?
5 Replies
1 Reply
Perfect, thanks, exactly what I was looking for. though it don’t really work the way i want it, cause max basically freezes.
Just as a test I want to have an object rotate without the “time slider” moving.
mybox = box()
for i = 1 to 10 do
(
windows.processPostedMessages()
rotate mybox (eulerangles 0 0 10)
sleep 1
)
1 Reply
Yeah thanks, now it works exactly how I wanted it
Example code:
mybox = box()
theTimer = dotNetObject "System.Windows.Forms.Timer"
fn rotateBox = (
If ( isValidNode mybox ) then
(
rotate mybox (eulerangles 0 0 10)
)
else
(
theTimer.stop()
)
)
dotnet.addEventHandler theTimer "tick" rotateBox
theTimer.interval = 1000
theTimer.start()
--theTimer.stop()
EDIT Added a check if box deleted so, max dont crash if you would delete the box.
Jun 05, 2014 9:33 pm
Hi, I have used timer in one of my past time scripts. You can find how I have done thru using timer in the stop watch script… you can find them @: