Jump to content
Sign in to follow this  
ChaosRaine

Trying to combine animation scripts

Recommended Posts

I have a script then animates a nearby avatar on touch and one the animates on attach. I want to run these in the same script, but I'm having trouble with the combo of permissions. Any ideas? Here's what I'm using

Animate on Touch

//Touch and get near avatars in a dialog menu.
//menu listener
integer listener;
integer sensorChannel;
// range and arc for the sensor
float range = 15.0;
float arc = PI;
list avatarsKeys;
list avatarsNames;
integer permissions;
menu(key user,integer channel,string title,list buttons)
{
    listener = llListen(channel,"","","");
    llDialog(user,title,buttons,channel);
    //remove listener if there's no activity in menu
    llSetTimerEvent(20.0);
}
integer randomNumber()
{
    return (integer)(llFrand(99999.0) * -1);
}
default
{
    touch_start(integer total_number)
    {
        //only owner can access the menu
        if (llDetectedKey(0) == llGetOwner())
        {
            llSensor("","",AGENT,range,arc);
        }
    }
    sensor(integer total_number)
    {
        integer i;
        key tempId;
        avatarsKeys = [];
        avatarsNames = [];
        i = 0;
        while ((i < total_number) && (i < 12))
        {
            tempId = llDetectedKey(i);
            avatarsKeys = avatarsKeys + tempId;
            avatarsNames = avatarsNames + llKey2Name(tempId);
            i = i+1;
        }
        sensorChannel = randomNumber();
        menu(llGetOwner(),sensorChannel,"Select an avatar...",avatarsNames);
    }
    listen(integer channel,string name,key id,string message)
    {
        if (channel == sensorChannel)
        {
            integer pos = llListFindList(avatarsNames,[message]);
            if (pos > -1)
            {
//                llSay(0,message + "'s key is " + llList2String(avatarsKeys,pos));
        llRequestPermissions(llList2String(avatarsKeys,pos), PERMISSION_TRIGGER_ANIMATION );
            }
        }
    }
     run_time_permissions(integer permissions)
    {
        if (permissions & PERMISSION_TRIGGER_ANIMATION)
        {      
            llStartAnimation( llGetInventoryName(INVENTORY_ANIMATION, 0) );
         
        }
}
}

 

 

Animate on Attach

 

default
{
    state_entry() 
    {
        }
   
        attach(key attached)
    {
        if (attached != NULL_KEY)   
        { 
    
   
        llRequestPermissions( llGetOwner(), PERMISSION_TRIGGER_ANIMATION );
}

}
  
 run_time_permissions(integer permissions)
    {
        if (permissions & PERMISSION_TRIGGER_ANIMATION)
        {      
            llStartAnimation( llGetInventoryName( INVENTORY_ANIMATION, 0) );
         
        }
        else
        {
            llResetScript();
        }
    }
}

 

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...