test for animation end
|
Brendan Etzel
Registered User
Join date: 22 Jul 2007
Posts: 33
|
01-25-2010 12:37
Is there a way for a script to know if an animation has ended? So far I am using a timer, which is not very accurate.
start animation1 on completion do something....
start animation2 on completion do something....
etc...
Hope this makes sense,
Thanks,
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-25-2010 12:55
nope =/
you can get sequential animation with gestures, but that's about it
ETA: well I suppose you could constantly poll the playing animations, but that isn't very accurate or useful either... since it'll have gaps between playing... sorry.
you COULD try overlapping the animations, by making ones that have a steady portion at the end, or looped end frames, and then playing the next one over it, then stop the previous one.. but that's a HUGE amount of extra work, and it still won't be perfect
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Brendan Etzel
Registered User
Join date: 22 Jul 2007
Posts: 33
|
01-25-2010 13:38
OK thanks Void,
Reading the Wiki I feared that would be the case. It seems you can't run multiple timers in parallel either.
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-25-2010 14:31
From: Brendan Etzel OK thanks Void,
Reading the Wiki I feared that would be the case. It seems you can't run multiple timers in parallel either. actually you can... a cheap way to get 2 is to use llSensor repeat with an impossible to detect item, and then treat the no_sensor event as a timer... I don't actually recommend that by the way, but it works. the otherway would be to multiplex the timer, and use conditional logic in it to decide which timer code is going to run... for examples, 3 timers, a=2, b=3, c=5 get the greatest common divisor (like the greatest common factor, except fractions are ok) for all the timers (1 in this case), and label that d. divided the separate timer intevals by the global timer interval to get your test point as an integer (so that modulus works for ease of math) then in your timer check if it's time to fire that specific timer event integer counter;
default{ state_entry(){ llSetTimerEvent( 1.0 ); //-- our greatest common divisor }
timer(){ if (!(counter % a)){ //-- (a /= d) llOwnerSay( "2 second timer fired" ); } if (!(counter % b)){ //-- (b /= d) llOwnerSay( "3 second timer fired" ); } if (!(counter % c)){ //-- (c /= d) llOwnerSay( "5 second timer fired" ); } ++counter; } }
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
01-25-2010 14:32
From: Brendan Etzel It seems you can't run multiple timers in parallel either. No, but you can fake nesting them. Suppose you use llSetTimerEvent(2) and then set a counter in the timer event to do something special every 5 cycles? That way you'd effectively have a 2-second timer and a 10-second timer nested in one event. You could nest several levels that way, in fact, so long as the successive outer layers of the nest were counting successively larger multiples of 2 seconds. ETA: Ahh....... What she said... 
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-25-2010 14:34
almost caught me there 
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
01-25-2010 18:01
Multiple scripts too...
_____________________
My tutes http://www.youtube.com/johanlaurasia
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
01-26-2010 05:46
Would something based on this work? list anims_and_times= [ "anim1", 1.0, "anim2", 2.0, "anim3", 3.0 ];
integer counter; integer max; integer strides = 2;
float t;
list temp; string current_anim;
integer fncStrideCount(list lstSource, integer intStride)// Returns number of Strides in a List { return llGetListLength(lstSource) / intStride; }
// Returns a Stride from a List list fncGetStride(list lstSource, integer intIndex, integer intStride) { integer intNumStrides = fncStrideCount(lstSource, intStride); if (intNumStrides != 0 && intIndex < intNumStrides) { integer intOffset = intIndex * intStride; return llList2List(lstSource, intOffset, intOffset + (intStride - 1)); } return []; }
default { state_entry(){ max = fncStrideCount(anims_and_times,strides); }
touch_start(integer total_number){ counter = 0; temp = fncGetStride(anims_and_times,counter,strides); current_anim = llList2String(temp,counter); t= llList2Float(temp,1); llOwnerSay(current_anim+": "+(string)t); counter++; llSetTimerEvent(t); } timer(){ temp = fncGetStride(anims_and_times,counter,strides); current_anim = llList2String(temp,0); t= llList2Float(temp,1); llOwnerSay(current_anim+": "+(string)t); counter++; if(counter>max){ t=0.0; llOwnerSay("stopping"); } llSetTimerEvent(t); } }
|
Twisted Pharaoh
if ("hello") {"hey hey";}
Join date: 24 Mar 2007
Posts: 315
|
01-26-2010 21:47
Why not check the animations list? default { state_entry() { llSetTimerEvent(1.0 ); }
timer() { integer anim_count = llGetListLength(llGetAnimationList(llGetOwner())) ; string anim = (string)anim_count + " animation" ; if (anim_count != 1) anim += "s" ; llOwnerSay(anim + " playing.") ; } }
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-26-2010 22:07
because you'd have to poll it pretty fast and it'd still have gaps (although perhaps not as quite bad as a countdown timer)... very sim unfriendly.
plus there's the problem that it returns keys to be worked around
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Twisted Pharaoh
if ("hello") {"hey hey";}
Join date: 24 Mar 2007
Posts: 315
|
01-26-2010 22:18
You could check the anim count every second and check if the count changed plus peek into the list every 5 seconds "just in case". Depends on your exact needs though. If you can rely on the fact that only your script is adding anims then you would be pretty safe with the count.
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-27-2010 00:34
well then your gap between overlapping anims could be as much as 1 sec under normal conditions (more if time dilation goes up), and as for depending on yours being the only animations playing... all I can say is "AO"
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Brendan Etzel
Registered User
Join date: 22 Jul 2007
Posts: 33
|
01-28-2010 05:06
I've been tinkering with the script and animations a bit more. The results are not very consistent because the delay between starting the next animations seems to vary. What works best so far is using one long animation and use a timer
What I want is this: Take a phone from your pocket, bring it to your ear , talk ,and put it back in pocket
after x frames make pocketphone visible, after y frames make earphone visible prety much like a gun and holster script
I feel I am getting there.....eventually
|
Twisted Pharaoh
if ("hello") {"hey hey";}
Join date: 24 Mar 2007
Posts: 315
|
01-28-2010 05:39
Well then if you know the animation key you can look into the animation list if it is playing. You can grab the key easily with Emerald by the way.
|
jeaniesing Trilling
Loves to animate & script
Join date: 21 Oct 2006
Posts: 61
|
01-28-2010 13:20
From: Brendan Etzel I've been tinkering with the script and animations a bit more. The results are not very consistent because the delay between starting the next animations seems to vary. What works best so far is using one long animation and use a timer
What I want is this: Take a phone from your pocket, bring it to your ear , talk ,and put it back in pocket
after x frames make pocketphone visible, after y frames make earphone visible prety much like a gun and holster script
I feel I am getting there.....eventually the problem with one animation is that animations play at different rates on different clients... an example, I started two instances of SSl on my screen and had my alt dance with my main alt. Two screens on one computer showed two entirely different places in the dance. The phone will be visible/invisible on a strict timer that has little to do with the animations. because I animate (and script) i would say you can make it "good enough" - but don't kill yourself going for perfection, it won't happen 
_____________________
  Pinastri/113/171/30
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
01-28-2010 13:49
I don't make animations but I work very closely with someone who does, and I wholeheartedly agree with jeaniesing.
For what it's worth, we've found we get the best (though by no means perfect) results for the minimum of effort by her making animations with transitions that allow for the fact I'm never going to be able to guarantee to stitch them and other effects together seamlessly by script and then using a timer based on the upload timings the viewer gives her rather than what Poser tells her (the two seem to differ now and again).
I tried polling llGetAnimationList but the results seemed no better and, if anything, even less predictable.
|