Jump to content

Use temp attachment and have object animate the avatar


Amethyst Jetaime
 Share

You are about to reply to a thread that has been inactive for 4161 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

If you want to use llAttachToAvatarTemp and then animate the avatar on attachement, how would you handle permissoins since you need two?  I got the script to ask permissions for both events and then the object attaches if permission is granted, but the animation will not run if permissoin is granted for that  too.  I keep getting a script error :
Script trying to trigger animations but PERMISSION_TRIGGER_ANIMATION permission not set

 

Link to comment
Share on other sites

You need to ask for permissions again, once the item is attached (if it doesn't belong to you before it attaches, it loses all perms when it does attach).

So all you need to do is something like 

default{	state_entry()	{		//llSay(0, "Hello, Avatar!");	}	attach(key attached)	{		if(attached){			llRequestPermissions(attached,PERMISSION_TRIGGER_ANIMATION|PERMISSION_ATTACH);//and so on		}	}	run_time_permissions(integer permissions)	{		if(permissions & PERMISSION_TRIGGER_ANIMATION){			llStartAnimation("my anim");		}	}}

 

You can request as many permissions as you like at once, using a pipe symbol, |, to concatenate them, and you can request them as often as you like, but keep in mind that each time you request permissions, that completely over-writes any previous ones the script may have.

Link to comment
Share on other sites

I really ought to add another example to the wiki page, because this is not very clear. Here's the background logic for llAttachToAvatarTemp.  You cannot attach an object unless you own it, and you also cannot attach something with a script unless the script has asked and received PERMISSION_ATTACH.  The trick in llAttachToAvatarTemp is that it transfers ownership as soon as you grant that permission.  A side effect is that you are longer the person who was granted permission -- you have gone from non-owner to owner.  So, in order to animate your av, the script has to ask PERMISSION_TRIGGER_ANIMATION after the object has attached.  It also has to requerst PERMISSION_ATTACH again, because without it, the script won't obey a llDetachFromAvatar command when you issue one.  The second llRequestPermissions, then, has to be PERIMSSION_TRIGGER_ANIMATION | PERMISSION ATTACH.

integer gAttach = TRUE;default{    touch_start(integer num)    {        if (gAttach)        {            llRequestPermissions(llDetectedKey(0),PERMISSION_ATTACH);            gAttach = FALSE;        }        else        {            if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION | PERMISSION_ATTACH)            {                llDetachFromAvatar();            }        }    }    attach(key id)    {        if (id)        {            llRequestPermissions(id,PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);        }    }    run_time_permissions (integer perm)    {        if (!gAttach)        {            if (perm & PERMISSION_ATTACH)            {                gAttach = TRUE;                llAttachToAvatarTemp(ATTACH_HEAD);            }        }        else        {            if (perm & PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION)            {                llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));            }        }    }}

 

 EDIT:  Hah!   Innula types faster than I do.  :D

 

Link to comment
Share on other sites

tried this in a box i rezzed on the ground...seems to work.

 

default{    state_entry()    {       key  ID = llGetOwner();       llRequestPermissions(ID,PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);    }    touch_start(integer total_number)    {           }          run_time_permissions(integer perm)                                      {         if( perm & PERMISSION_ATTACH )        {            llAttachToAvatarTemp( ATTACH_LHAND );        }                     if (perm & PERMISSION_TRIGGER_ANIMATION)        {            llStartAnimation("sit");                   }    }}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4161 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...