D-Animator

Thread Started By deadpool

2166
0
  • 41 Vote(s) - 3.02 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rate Thread
#1
What is it?

It’s NOT an AO, it was created as an extension to an existing AO, giving further control over what animation you want to play. Made to hold hundreds and hundreds of animations. I added also the option to animate someone else, using sensor to scan nearby (96m range) for other avatars. Although made to work using a single prim, it uses llDetectedTouchFace to utilize two faces of one prim, one face when touched, opens a menu, the other stops any and all animations playing.

How-to/Info:

•Copy paste the script below into a new script inworld.
•Save it & then put the script into an object (if not there already).
•Taper the prim so faces 1 and 3 are facing the same direction.
(Taper X = 0.0 Y = 1.00, Top Shear X = 0.0 Y = -0.25)
•Shrink the object so it better fits a HuD position.
•Wear it as a HuD attachment and add some animations.
•Touch it.

PHP Code:
//Made for a single 2 faced button =) Use taper;
//Updates will be kept at the Open Source ReSource.
//Face 1 = Stop animations & play undeformer animation;
//Face 3 = Menu;
 
key owner;
key Animate;
key reqid;
string Animation;
integer dMenu;
integer Parts;
list 
AnimButtons;
list 
tList;
string URL "http://w-hat.com/name2key";
//UDF to create list from prims inventory
aLoad(){integer i;
    
tList = [];
    
Parts=0;
    for(
i=0< = -llGetInventoryNumber(INVENTORY_ANIMATION);i++){
        
tList += [llGetInventoryName(INVENTORY_ANIMATION,i)];
        
Parts++;
    }
}
//UDF to build dialog from list
aMenu(){integer i;
    
llSetTimerEvent(45.0);
    
AnimButtons = [];
    if(
dMenu 0)
        
AnimButtons += ["< <•"];
    else
        
AnimButtons += ["•"];
    
AnimButtons += ["1st Page"];
    if(
dMenu*8+Parts 1)
        
AnimButtons += ["•>>"];
    else
        
AnimButtons += ["•"];
    for(
i=dMenu*8; (< = dMenu*8+8) && (<= Parts 1);i++){
        
AnimButtons += [llGetInventoryName(INVENTORY_ANIMATIONi)];
    }
    
llDialog(llGetOwner(), "
    *Select desired Animation;
 
    (Select \"Ignore\" when done;)
 
    ((Note~ You can add anims to this button ;))"
AnimButtonsmyChannel);
}
//UDF to stop animations & play underformer animation
StopAnims(){integer n;
    list 
anims llGetAnimationList(llGetOwner());
    for ( 
n=0n<llGetListLengthanims ) ;n++ ){
        
llStopAnimationllList2Stringanims,));
    }
    
llStartAnimation("*Undeformer*"); 
    
llStartAnimation("stand");   
}
StopTheirAnims(){integer n;
    list 
anims llGetAnimationList(Animate);
    for ( 
n=0n<llGetListLengthanims ) ;n++ ){
        
llStopAnimationllList2Stringanims,));
    }
    
llStartAnimation("*Undeformer*"); 
    
llStartAnimation("stand");   
}
//Our menu lists
integer myChannel;//Out menu(s() channel
integer Listen;//Our handle to remove the listen by timer
list MainButtons = ["!Follower","R-P-S","Anims","Expressions","Emotes","SL Anims","•","STOP","•","•","Anim Some1","•"];
list 
rspButtons = [ "-Main-","•","•","Rock","Scissors","Paper","•","Countdown","•"];
list 
FollowerButtons = [ "-Main-","•","•","•","Down","•","Left","Center","Right","Forward","Up","Back"];
list 
slAnimButtons = [ "-Main-","away","`0' >>","angry_tantrum","angry_fingerwag","backflip","blowkiss","clap","dead","jumpforjoy","kissmybutt","peace"];
list 
slAnimButtons2 = [ "< < `0'","point_me","point_you","salute","stretch","whistle","wink_hollywood","yes_happy","yes_head"];
list 
ExpressionButtons = [ "-Main-","afraid","^_^ >>","anger","bored","cry","disdain","embarrased","frown","kiss","laugh","open_mouth"];
list 
ExpressionButtons2 = [ "< < ^_^","smile","tongue_out","toothsmile","sad","repulsed","shrug","surprise","wink","worry"];
list 
EmoteButtons = [ "-Main-","afraid","*_* >>","anger","bored","cry","embarrassed","laugh","repulsed","sad","shrug","surprise"];
list 
EmoteButtons2 = [ "< < *_*","wink","worry"];
//Our dialog User Defined Functions
MainMenu(){
llDialog(owner"
*!Follower = Anti-Follower anims.
*R-P-S = Rock, Paper, Scissors.
*Anims = This buttons inventory list.
*Expressions = SL inbuilt expressions.
*Emotes = SL inbuilt emotes.
*STOP = Stop all animations.
*Anim Some1 = Animate someone else.
*SL Anims = Anims not fitting into emote or expressions category."
MainButtonsmyChannel);
    
llSetTimerEvent(30.0); 
}
rspMenu(){
llDialog(owner"\n\n*These anims allow you to play the \"Rock, Paper, Scissors\" game with friends :)\n\nNOTE >> Remove this script & drop it into a box & pass to your friend if they don't have dhud =)\n\n              (Select \"Ignore\" when done;)"rspButtonsmyChannel);
    
llSetTimerEvent(30.0); 
}
slAnimMenu(){
llDialog(owner"\n\n*These are all random in nature, SL anims that aren't emotes etc.\n\n              (Select \"Ignore\" when done;)"slAnimButtonsmyChannel);
    
llSetTimerEvent(30.0);  
}
slAnimMenu2(){
llDialog(owner"\n\n*These are all random in nature, SL anims that aren't emotes etc.\n\n              (Select \"Ignore\" when done;)"slAnimButtons2myChannel);
    
llSetTimerEvent(30.0); 
}
FollowerMenu(){
llDialog(owner"\n\n*These options let you move your \"Visible\" avatar position, this helps make some nasty followers useless or less effective.\n\n              (Select \"Ignore\" when done;)"FollowerButtonsmyChannel);
    
llSetTimerEvent(30.0); 
}
ExpressionMenu(){
llDialog(owner"\n\n*These options will animate your face (Facial Expressions), often for only a very brief period.\n\n              (Select \"Ignore\" when done;)"ExpressionButtonsmyChannel);
    
llSetTimerEvent(30.0); 
}
ExpressionMenu2(){
llDialog(owner"\n\n*These options will animate your face, often for only a very brief period.\n\n              (Select \"Ignore\" when done;)"ExpressionButtons2myChannel);
    
llSetTimerEvent(30.0); 
}
EmoteMenu(){
llDialog(owner"\n\n*These options will animate your face (Facial Emotes), often for only a very brief period.\n\n              (Select \"Ignore\" when done;)"EmoteButtonsmyChannel);
    
llSetTimerEvent(30.0); 
}
EmoteMenu2(){
llDialog(owner"\n\n*These options will animate your face (Facial Emotes), often for only a very brief period.\n\n              (Select \"Ignore\" when done;)"EmoteButtons2myChannel);
    
llSetTimerEvent(30.0); 
}
OurListen(){
    
Listen llListen(myChannel""owner"");  
}
//Our sensor menu
float ScanRadius 50;
integer aSwitch 0;//switch to know whether loading inventory anims is for us or another av
integer gPos 0;
integer gStride 9;
list 
names;
list 
fullname;
Sensor3D(){
    
integer nTop gPos gStride -1;
    list 
buttons llList2List(namesgPosnTop);
    
string msg llDumpList2String(buttons"\n");
    while(
llGetListLength(buttons) % != 0){ 
        
buttons llListInsertList(buttons, [" "], gStride);
    }
    if (
gPos >= gStride){
        
buttons += ["< <Back"];
    }
    if (
nTop llGetListLength(names)){
        
buttons += ["Next>>"];
    }
    
llDialog(owner"\nSelect your desired target;\n\nNOTE>> Select \"*Undeformer*\" to STOP animations for the given target."buttonsmyChannel);
}
// UDF to return full name if cut by llGetSubString
string Name_2_full(string str1){
    
integer u=0;
    for(;
llGetInventoryNumber (INVENTORY_ANIMATION);u++){
         if(
llGetSubString(llGetInventoryName(INVENTORY_ANIMATION,u),0,23)==str1)
         return 
llGetInventoryName(INVENTORY_ANIMATION,u);
    } 
    return 
"";
}
 
default{
//
    
state_entry(){
        if (
llGetAttached())
        
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);
        
owner llGetOwner();
        
myChannel = (integer)llFrand(DEBUG_CHANNEL) * -1;
        
Animation llGetInventoryName(INVENTORY_ANIMATION,0);  
        
//llOwnerSay((string)llGetLinkNumber()); 
    

//
    
on_rez(integer change){
        
llResetScript();
    }
//
    
no_sensor(){
        
llOwnerSay("/me >> Nobody detected within "+(string)ScanRadius+"m;");
        
MainMenu();
    }
// Sensor used to grab nearby names 
    
sensor(integer num_detected){ 
        
names = [];
        
fullname = [];
        
gPos 0;
        
integer i;
        for (
0num_detectedi++){
            
names names llGetSubString(llDetectedName(i),0,23);
            
fullname fullname llDetectedName(i);
        }
        
Sensor3D();
    }
// link message to handle button texture change
    
link_message(integer senderinteger numstring strkey id){
        if (
str == "ANIM>>STOP2"){
            
StopAnims();
        }  
        else if (
str == "ANIMATION>>CTRL"){
            
OurListen();
            
MainMenu();
        }    
    }
//
    
touch_start(integer num_detected){integer i;
        
aSwitch 0;
        for (
0num_detectedi++){
            
integer touchedFace llDetectedTouchFace(i);
            if (
touchedFace == -1){OurListen();
                
MainMenu();
                
llOwnerSay("Sorry, your viewer doesn't support touched faces;
                (opening menu instead, select STOP from there to stop anims;)"
);
            }
            if (
touchedFace == 3){
                
OurListen();
                
MainMenu();
            }
            if (
touchedFace == 1){StopAnims();
                
llOwnerSay("/me Stopped & Reset `0'");
            }
        
// Some effects for button;
        
vector oldColor llGetColor(touchedFace);// Store away the original color
        
llSetColor(<0.255.0.>, touchedFace);// Flash color
        
llSleep(0.04);
        
llSetColor(oldColortouchedFace);// Put the color back to how we found it.
        

    }
//
    
timer(){//timer is for nothig but removing the listen/lag in this script
        
llSetTimerEvent(0.0);//we dont want to keep removing listen... so we stop timer
        
llListenRemove(Listen);//then do what we are here for.. remove listen/lag.
    
}   
//
    
listen(integer chanstring whokey idstring what){
        if(
chan == myChannel && llGetOwnerKey(id) == llGetOwner()){
            
string exp "express_"+what;
            
string em exp "_emote";
            
//Main menu list
            
if (llListFindList(MainButtons, [what]) != -1){//if the message if on our list of buttons
                
if(what == "STOP"){StopAnims();
                    
llOwnerSay("/me >> Stopped & Reset `0'");
                }
                else if(
what == "Anim Some1"){aSwitch 1;
                    
aLoad();  
                    
aMenu();
                }
                else if(
what == "R-P-S"){rspMenu();
                }
                else if(
what == "SL Anims"){slAnimMenu();
                }
                else if(
what == "Emotes"){EmoteMenu();
                }
                else if(
what == "Expressions"){ExpressionMenu();
                }
                else if(
what == "!Follower"){FollowerMenu();
                }
                else if(
what == "Anims"){dMenu=0;
                    
aSwitch 0;
                    
aLoad();
                    
aMenu();
                }return;
            }
            
//Rock Scissors Paper menu list
            
else if (llListFindList(rspButtons, [what]) != -1){//if the message if on our list of buttons
                
if(what == "-Main-"){MainMenu();
                }
                else if(
what == "Paper"){llStartAnimation("rps_paper");rspMenu();
                }
                else if(
what == "Rock"){llStartAnimation("rps_rock");rspMenu();
                }
                else if(
what == "Scissors"){llStartAnimation("rps_scissors");rspMenu();
                }
                else if(
what == "Countdown"){llStartAnimation("rps_countdown");rspMenu();
                }return;
            }
            
//SL animations menu list
            
else if (llListFindList(slAnimButtons, [what]) != -1){
                if(
what == "-Main-"){MainMenu();
                }
                else if(
what == "`0' >>"){slAnimMenu2();
                }
                else{
llStartAnimation(what);
                    
slAnimMenu();
                }return;
            }
            else if (
llListFindList(slAnimButtons2, [what]) != -1){
                if(
what == "< < `0'"){slAnimMenu();
                }
                else{
llStartAnimation(what);
                    
slAnimMenu2();
                }return;
            }
            
// Emote menu list
            
else if (llListFindList(EmoteButtons, [what]) != -1){
                if(
what == "-Main-"){MainMenu();
                }
                else if(
what == "*_* >>"){EmoteMenu2();
                }
                else{
llStartAnimation(em);
                    
EmoteMenu();
                }return;
            }
            else if (
llListFindList(EmoteButtons2, [what]) != -1){
                if(
what == "< < *_*"){EmoteMenu();
                }
                else{
llStartAnimation(em);
                    
EmoteMenu2();
                }return;
            }
            
// Expression menu list
            
else if (llListFindList(ExpressionButtons, [what]) != -1){
                if(
what == "-Main-"){MainMenu();
                }
                else if(
what == "^_^ >>"){ExpressionMenu2();
                }
                else{
llStartAnimation(exp);
                    
ExpressionMenu();
                }return;
            }
            else if (
llListFindList(ExpressionButtons2, [what]) != -1){
                if(
what == "< < ^_^"){ExpressionMenu();
                }
                else{
llStartAnimation(exp);
                    
ExpressionMenu();
                }return;
            }
            
// Follower menu list
            
else if (llListFindList(FollowerButtons, [what]) != -1){
                if(
what == "-Main-"){MainMenu();
                }
                else if(
what =="Center"){StopAnims();
                    
FollowerMenu();
                }
                else{
                    if(
aSwitch == 0){llStartAnimation(what);
                        
FollowerMenu();
                    }
                    else{
aMenu();
                    }
                }return;
            }
            
// Anim menu list (prim inventory
            
else if (llListFindList(AnimButtons, [what]) != -1){
                if(
what == "•"){return;
                }
                else if(
what == "<<•"){dMenu--;
                    
aMenu();
                }
                else if(
what == "1st Page"){dMenu=0;
                    
aMenu();
                }
                else if(
what == "•>>"){dMenu++;
                    
aMenu();
                }
                else if (
llListFindList(tList, [Name_2_full(what)]) != -1){
                    
Animation Name_2_full(what);
                    if(
aSwitch == 0){//if we are set to animate ourselves..
                        
llStartAnimation(Animation);
                        
aMenu();return;
                    }
                    else{
//else we must be asked to animate someone else
                        
llSensor("","",AGENT,ScanRadius,TWO_PI);
                    }
                } 
            }
            else{
                
reqid llHTTPRequest(URL+"?terse=1&name="+llEscapeURL(what),[],"");
            }
        }
    }
//
    
http_response(key idinteger status, list metastring body){
        if (
id != reqid)
        return;
        if((
key)body == NULL_KEY)
        
llOwnerSay("/me >> No key found.. Perhaps a new avatar.");
        else
        
Animate body;
        
llRequestPermissions(Animate,PERMISSION_TRIGGER_ANIMATION);
    }
//
    
run_time_permissions(integer perm){
        if(
aSwitch == 1){//if we are set to animate someone
            
if(perm){//if we got their permission
                
StopTheirAnims();
                
llStartAnimation(Animation);
                
llOwnerSay("/me >> "+llKey2Name(Animate)+" Accepted your request~");
                
MainMenu();
            }
            else{
//if we dont have their permission
                
llOwnerSay("/me >> "+llKey2Name(Animate)+" Declined your request~");
                
MainMenu();
            }
        }
        else{
//we have perms for ourselves.. do nothing
        
}
    }
//

Reply




Possibly Related Threads…
Thread Author Replies Views Last Post
  Animator Script Ap0110 2 3,173 06-19-2019, 04:35 AM
Last Post: snehagenna

Forum Jump:

1 Guest(s)
Share this:

About Second Life Copybot

Second Life CopyBot Forum is a place where you can get items for Second Life and other vitual worlds for free. With our CopyBot viewers you can export and import any content from these virtual worlds and modify them in 3D software such as Blender, 3D studio Macx etc...