Jump to content

Detect upon collision if avatar has oject attached


naughtyniece
 Share

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

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

Recommended Posts

Hi,

I have a prim on the floor and i can detect collision_start to tell me the avatar as stepped on it. However i would like to detect if the avatar has an object (a broom) attached to their left hand.

I found this but do not understand how to place it in a script

integer isObjectAttachedToAvatar( key object, key avatar ){
    return
      !llGetObjectPrimCount( object ) &    //-- must be attached to someone
      (llGetOwnerKey( object ) == avatar); //-- must be owned by the same person
}

My script detects collision and starts and animation, but i only want that to happen IF they have the broom attached.

collision_start(integer count)
     {
          key avatar = llDetectedKey(0);
            
            displayName = llGetDisplayName(avatar);
            if (avatar) llRequestPermissions (avatar, PERMISSION_TRIGGER_ANIMATION);
            else llStopAnimation (animation);
        }

Also i would ideally like it not to ask if they wish to animate... but thats a seperate question i guess.

 

Thank you for your help

Suzie

Link to comment
Share on other sites

I agree that the Scripting Forum is probably the best place to ask this.

However, since we're here, let's take a look!   

You need to be a bit clearer, I think, about why you want to know if someone has a broom attached.   The newish function llGetAttachedList  will be a help if that's all you need to know, but if you want to know because you want to animate them, would it be possible to put the animation in the broom and have the collision prim use llRegionSayTo(avatar, someChannel,"Sweep!); ? That way, any attachment the avatar is wearing that's listening on someChannel will hear the command.   

That has the advantage that scripts in attachments can ask for, and automatically be granted, permission to animate the avatar without bothering with a dialog.

 

  • Like 2
Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...