Looks to me as if the problem might be with the while loop. It allows the frame 41 to be used when it does not exist. It should be:
Code:
{ my->frame += 1*time_step;
if(my->frame >= 41) my->frame -= 40;
wait(1);
}
or:
Code:
{ my->frame += 1*time_step;
my->frame %= 41;
wait(1);
}
at least that's how to use the modulo operator in c-script
cheers
edit: Also wonder why you want to tie the frame number to time_step and not the time each frame is shown. It should really be:
Code:
{
my->frame += 1;
my->frame %= 41;
wait(-time_step); // multiply with 0.01 ... 100 to adjust length
wait(1);
}