Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: KDC animator, fastest smallest Animation overrider

Kyrah Abattoir
cruelty delight
Join date: 4 Jun 2004
Posts: 2,786
07-01-2005 16:43
OKOK i wrote this little script in the hope of less clunky server eating animation overriders that are widely used in sl, this AO is as small as i have been able to do it, and as you can see it is also using very few instructions.
by the way the pulse speed do not affect the time between the animation change

ENJOY !!
if there is any questions feel free to ask

P.S i havent included fancy stuffs like the AO toggle command or multiple stand anim, i bet you can easily adapt this script to your liking
CODE

// KDC's shortest Aniamtion overrider in SL
// Copyright (C) 2005 Kyrah Abattoir
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

//there we go...
float pulse = 0.1;//the time between each check, adjust it to your liking
//bigger == slower == low resources

//if a state isnt in the list its just ignored, you can add new overriding states here
list states = ["Standing","Walking","Hovering","Crouching","Hovering","Jumping","PreJumping","Running","Sitting","Sitting on Ground",
"Flying","FlyingSlow","Falling Down","Soft Landing","CrouchWalking"];

//list of ther anims yo will use instead if the value == pass on, we let the anim play. One anim per state
list anims = ["ballet stand","ballet walk 2","ballet foots","ballet foots","ballet foots","ballet foots","ballet foots","ballet foots","ballet foots","ballet foots","ballet foots","ballet foots","ballet foots","ballet foots"];
//ok this is filled with MY animations of course you will change it to yours if you want it to work, right?

string anim_overrided= "";
string curr_anim= "";
default
{
attach(key id)
{
if(id == NULL_KEY && curr_anim != "")//IF detached and an animation is running
llStopAnimation(curr_anim);//stop the anim
else
llResetScript();
}
state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);//we ask for permissions
}
run_time_permissions(integer perms)
{
llSetTimerEvent(pulse);//we set the main pulse
}
timer()
{
string anim_state = llGetAnimation(llGetPermissionsKey());
if(anim_state == "Turning Left" || anim_state == "Turning Right")//this is a little HACK to remove the turn left and right
anim_state = "Standing";
integer anim_index = llListFindList(states,[anim_state]);
if((anim_index != -1) && (anim_overrided != anim_state))//IF we havent specified this anim must be ignored
{
anim_overrided = anim_state;
//llSetText("",<1,1,1>,1.0);//DEBUG displaying the state
if(llList2String(anims,anim_index) == "PASS_ON")
{
if(curr_anim != "")
llStopAnimation(curr_anim);
curr_anim = "";
}
else
{
string stop_anim = curr_anim;
curr_anim = llList2String(anims,anim_index);
if(stop_anim != "")
llStopAnimation(stop_anim);
if(curr_anim != stop_anim)//if its the same anim we already play no need to change it
llStartAnimation(curr_anim);
if(anim_state == "Walking")//another lil hack so the av turn itself 180 when walking backward
llStopAnimation("walk");//comment these 2 lines if you have a real backward animation
}
}
}
}
_____________________

tired of XStreetSL? try those!
apez http://tinyurl.com/yfm9d5b
metalife http://tinyurl.com/yzm3yvw
metaverse exchange http://tinyurl.com/yzh7j4a
slapt http://tinyurl.com/yfqah9u
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
07-04-2005 08:38
/15/2d/52260/1.html
_____________________
i've got nothing. ;)
Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
07-05-2005 22:29
From: Kyrah Abattoir
CODE

// Special thanks to Gwyneth Llewyn and Kex Godel for their technical
// suggestions and contributions, as well as their heroic documentation
// efforts.


Oops! It looks like you forgot to edit this part when you were copy/pasting from my script :)
_____________________
--
~If you lived here, you would be home by now~
si Money
The nice demon.
Join date: 21 May 2003
Posts: 477
07-06-2005 08:22
From: Francis Chung
Oops! It looks like you forgot to edit this part when you were copy/pasting from my script :)


Fran, we know you wouldn't use words like "overrided" ;)
_____________________
Like a soul without a mind
In a body without a heart
I'm missing every part

-- Progress --
Catherine Omega: Yes, but lots of stuff isn't listed. "Making UI harder to use than ever" and "removing all the necessary status icons" things.... there's nothing like that in the release notes. :)
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
07-06-2005 08:35
I can't get in-world right now because of the update, so I can't verify this, but it looks like the core AO logic is pretty much the same as Francis Chung's and others' AO scripts. All of the logic to configure the script using a notecard is gone, but that wasn't what the huge drain on server resources came from. This script still polls the current animation every 0.01 seconds (or whatever you choose), so how is it more efficient?
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
07-06-2005 09:13
I think we need an event oriented solution to the animation overriders. I think something like llAnimationDetect(key avatar) should be implemented, where if the script has PERMISSION_TRIGGER_ANIMATION from the key in question, the llAnimationDetect registers a callback for an animation_triggered(string animationName) event. Passing NULL_KEY to llAnimationDetect would remove the callback. This way we dont have to poll the result of llGetAnimationList in a fast timer.

If LL did this the "right" way, it would be infintely better for sim performance, since code won't need to run every 0.01 seconds, just only when an avatar's animations change.

If only I had some more feature suggestion votes :p
==Chris
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
07-06-2005 09:33
The variations aroung the moving_start() event ought to do this, there is at least one pseudo overrider that uses it, but they aren't as clean as Francis' version - the take control intercepts the keypushes and stops the default anims playing at all, whilst the moving_start based ones start you moving then kick in the new anim.

Working a way so that they ran nicely from the moving_start() event would be nice though. Pretty please Lindens?
Kyrah Abattoir
cruelty delight
Join date: 4 Jun 2004
Posts: 2,786
07-06-2005 11:47
From: Francis Chung
Oops! It looks like you forgot to edit this part when you were copy/pasting from my script :)


i am not very good at writing introductions XD
not even to copy paste them

i wouldnt say "clean" Eloise ...
_____________________

tired of XStreetSL? try those!
apez http://tinyurl.com/yfm9d5b
metalife http://tinyurl.com/yzm3yvw
metaverse exchange http://tinyurl.com/yzh7j4a
slapt http://tinyurl.com/yfqah9u
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
07-06-2005 17:58
I wish there was a way to over ride the defolt animations; with out using scripting. Just like people can set other carristics of an avatar.
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
07-07-2005 07:59
From: Eloise Pasteur
The variations aroung the moving_start() event ought to do this, there is at least one pseudo overrider that uses it, but they aren't as clean as Francis' version - the take control intercepts the keypushes and stops the default anims playing at all, whilst the moving_start based ones start you moving then kick in the new anim.

Working a way so that they ran nicely from the moving_start() event would be nice though. Pretty please Lindens?


Hmm. Interesting. I'm not sure from your description of this is how these work, but I have an idea for a hybrid that might be more efficient: rather than a timer, just run the code that normally runs in the timer() event inside a control and moving_start event. The logic is that the animations wouldn't be changing unless the avatar moves, and rather than trying to figure out from control input and such which direction an av is moving (and therefore which anims should be triggered), just do what the overriders do already. This could result in less frequent polling with the same net effect. The timer would probably still need to be there, say, every 0.5 seconds, to check for ambient animations like breathing and all that (that is, if those are overridable).

Thoughts?
Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
07-07-2005 08:25
From: Lex Neva
Hmm. Interesting. I'm not sure from your description of this is how these work, but I have an idea for a hybrid that might be more efficient: rather than a timer, just run the code that normally runs in the timer() event inside a control and moving_start event. The logic is that the animations wouldn't be changing unless the avatar moves, and rather than trying to figure out from control input and such which direction an av is moving (and therefore which anims should be triggered), just do what the overriders do already. This could result in less frequent polling with the same net effect. The timer would probably still need to be there, say, every 0.5 seconds, to check for ambient animations like breathing and all that (that is, if those are overridable).

Thoughts?


The moving_* events are mostly meaningless in an attachment.

Without a polling loop, there are some animation changes that you won't pick up, like the transition between hovering and falling.

That said, it's not entirely necessary to have a timer for *most* things. In my animation override script, you can turn off the timer entirely (and voice commands) if that's your thing.
_____________________
--
~If you lived here, you would be home by now~
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
07-07-2005 11:56
From: Kurt Zidane
I wish there was a way to over ride the defolt animations; with out using scripting. Just like people can set other carristics of an avatar.


I would like this as well.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
07-07-2005 14:31
From: Lex Neva
Hmm. Interesting. I'm not sure from your description of this is how these work, but I have an idea for a hybrid that might be more efficient: rather than a timer, just run the code that normally runs in the timer() event inside a control and moving_start event. The logic is that the animations wouldn't be changing unless the avatar moves, and rather than trying to figure out from control input and such which direction an av is moving (and therefore which anims should be triggered), just do what the overriders do already. This could result in less frequent polling with the same net effect. The timer would probably still need to be there, say, every 0.5 seconds, to check for ambient animations like breathing and all that (that is, if those are overridable).

Thoughts?


I will have a look and see if I can find the script, or remember who wrote the original. From memory it triggered when you moved obviously, and replaced various anims it 'got' with ones you told it to. I think it only replaced walk/run anims, but might work with others, although I bow to Francis' superior experience for overriding everything.
Kyrah Abattoir
cruelty delight
Join date: 4 Jun 2004
Posts: 2,786
08-22-2005 23:30
yeah i made some tests with moving start/end, it react completely erratically in an attachment.

The point of this ao was to write as less code as possible, using the magic of the lists to remove most of the logic.

seems that its something most havent understood, yeah of course i can add a notecard reader, that will not take more than 10 lines, but it wasn't the point
_____________________

tired of XStreetSL? try those!
apez http://tinyurl.com/yfm9d5b
metalife http://tinyurl.com/yzm3yvw
metaverse exchange http://tinyurl.com/yzh7j4a
slapt http://tinyurl.com/yfqah9u
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
08-23-2005 06:55
From: Kurt Zidane
I wish there was a way to over ride the defolt animations; with out using scripting. Just like people can set other carristics of an avatar.
Just making animations by priority 4? ;)
_____________________
:) Seagel Neville :)
a lost user
Join date: ?
Posts: ?
09-02-2005 01:29
From: Christopher Omega
I think we need an event oriented solution to the animation overriders. I think something like llAnimationDetect(key avatar) should be implemented, where if the script has PERMISSION_TRIGGER_ANIMATION from the key in question, the llAnimationDetect registers a callback for an animation_triggered(string animationName) event. Passing NULL_KEY to llAnimationDetect would remove the callback. This way we dont have to poll the result of llGetAnimationList in a fast timer.

If LL did this the "right" way, it would be infintely better for sim performance, since code won't need to run every 0.01 seconds, just only when an avatar's animations change.

If only I had some more feature suggestion votes :p
==Chris



Where do we vote?
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
09-02-2005 10:31
here
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
a lost user
Join date: ?
Posts: ?
09-02-2005 18:19
Thank you Christopher. I hope we can get more votes on this.
a lost user
Join date: ?
Posts: ?
Prop: 520
09-04-2005 20:49
Looking at the Proposal system it is easy for something as needed as this to be lost.

Christopher, could you maybe start a thread on this proposal to let people know that it exist and maybe we can get more votes on it.

I see Linden is working on a proposal to add one pony to SL so that we can have a pony ride...lol It won approval with 177 votes between 28 voters. So I think its not impossible for something needed like this to get approved with enough votes.
a lost user
Join date: ?
Posts: ?
09-08-2005 01:12
bump
BOSS Toonie
Registered User
Join date: 5 Jul 2005
Posts: 4
Overdriver
08-14-2007 15:47
Hello Kyrah Abattoir,,,
nice script ,, is there any way to run 2 or 3 anim for one stat such like standing ?
please help if any