Jump to content
Galatheus

Can't find a script that animates avatar on touch of a HUD button

Recommended Posts

You'd think there is, but why can't I find a script on MP that animates our avi on touch of a button.  I want to make a hud that triggers the animation inside another object, that's it no menu, just a HUD button that triggers the animation inside a wearable object, anyone?

Edited by Galatheus
  • Like 1

Share this post


Link to post
Share on other sites

this should work,

enjoy


integer anim_status;

default
{
    state_entry()
    {
    }
    
    on_rez(integer start_param)
    {
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
    }
    touch_start(integer detected)
    {
        if (anim_status)
        {
            llStopAnimation("sit");
            anim_status = 0;
        }
        else
        {
            llStartAnimation("sit");
            anim_status = 1;
        }
    }
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            return;
        }
    }
}

regards,

Dargo

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

code clean up

integer anim_status;
default
{    
    on_rez(integer start_param)
    {
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
    }
    touch_start(integer detected)
    {
        if (anim_status)
        {
            llStopAnimation("sit");
            anim_status = 0;
        }
        else
        {
            llStartAnimation("sit");
            anim_status = 1;
        }
    }
}

 

  • Like 1

Share this post


Link to post
Share on other sites

And to prevent any script errors...

integer anim_status;

default
{    
    on_rez(integer start_param)
    {
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
    }
    touch_start(integer detected)
    {
        if (llGetPermissionsKey() == NULL_KEY)
        {
            return;
        }

        if (anim_status)
        {
            llStopAnimation("sit");
            anim_status = 0;
        }
        else
        {
            llStartAnimation("sit");
            anim_status = 1;
        }
    }
}

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
7 hours ago, Galatheus said:

 I want to make a hud that triggers the animation inside another object, that's it no menu, just a HUD button that triggers the animation inside a wearable object, anyone?

two scripts are needed for this

1) HUD script that knows about the animation(s) in the other worn object
2) Animate script in the other worn object that contains the animation and holds the wearer's permissions

the Animate script listens for a message from the HUD

http://wiki.secondlife.com/wiki/Listen


pcode basics example for same owner of HUD and other worn object

// HUD script

integer CHANNEL = -161616;  // some channel number

touch_start(...)
{
    llWhisper(CHANNEL, "Name of animation");
}


// Animate script

state_entry
{
    llListen(CHANNEL, "", llGetOwner(), "");
    
    ... request owner permissions ...
}

listen (..., string text, ...)
{
   // check that script has permission
   if (llGetPermissionsKey() == llGetOwner())   
   {   
      // check that 'text' is an animation in Contents
      if (llGetInventoryType(text) == INVENTORY_ANIMATION) 
      {
         llStartAnimation(text);
        
         ... stop any previous started animation ...
      }
   } 
}

 

  • Like 1

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.


×
×
  • Create New...