Jump to content

Start animation after HUD answer, wrong function?


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

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

Recommended Posts

Hello. I'm creating an item to wear and let other avatars touch you, then user will react with love or hate.

The HUD is working OK. The problem is: after wearer's response, the avatar must react with an animation of love or disgust. I'm struggling to start the animation, probably something about permissions. 

Question:

- How can I start the animation without asking for permission? Or will it happen automatically?
- Am I using the wrong function (llStartAnimation)?

Excerpt:

else if (message == "Hate") {
	llInstantMessage(toucherID, "HATED IT!"); // to person who touched you
    run_time_permissions(integer perm) {
         if (perm & PERMISSION_TRIGGER_ANIMATION) {
			llStartAnimation("animation_name");
			llOwnerSay("test: end in 5 seconds");
			llSetTimerEvent(5.0);
         }
         timer() {
 	        llSetTimerEvent(0.0);
			llStopAnimation("animation_name");
		}
	}           
}

Thank you.

Link to post
Share on other sites
23 minutes ago, Ewadir said:

 

Did you run the llRequestPermissions( owner_id, PERMISSION_TRIGGER_ANIMATION ); function?

' How can I start the animation without asking for permission? Or will it happen automatically? ' you can not if you do not have experience sim usage.

Edited by steph Arnott
Link to post
Share on other sites
1 minute ago, steph Arnott said:

Did you run the llRequestPermissions( owner_id, PERMISSION_TRIGGER_ANIMATION ); function?

Yes, like this?

 touch_start(integer num_detected) {
        llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION); // from object owner

 

Link to post
Share on other sites
18 minutes ago, Ewadir said:

It returns a "syntax error" on  Line 101, that is: run_time_permissions(integer perm) {

state_entry()
    {
        llSetTimerEvent(0.0);
    }
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            llStartAnimation("Vanish");
            llSetTimerEvent(14.0);
        }
    }

You need to rearrange the code

Link to post
Share on other sites
13 minutes ago, Ewadir said:

I guess I'm using the wrong function... The right one seems to be http://wiki.secondlife.com/wiki/LlStartObjectAnimation (not working at the moment, anyway LOL)


 else if (message == "Hate") {
	llInstantMessage(toucherID, "HATED it!");
    llStartObjectAnimation("AnimationName");
}

 

Never heard of that one.  Still need to set the pems before that function.

Link to post
Share on other sites
1 hour ago, Ewadir said:

- How can I start the animation without asking for permission? Or will it happen automatically?
- Am I using the wrong function (llStartAnimation)?

llStartAnimation is correct, but the HUD must call llRequestPermissions before llStartAnimation, or you will get an error.

However, PERMISSION_TRIGGER_ANIMATION will be automatically granted (no permission dialog) after llRequestPermissions because the HUD is attached.

To make life easy, you should just put llRequestPermissions in the attach event, after making sure the HUD is attached. eg:

default
{
    attach(key id)
    {
        if(id) llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
    }
}

"if(id)" is the same as "if(id != NULL_KEY)"

Link to post
Share on other sites
45 minutes ago, steph Arnott said:

You do not put it there for the owner. It is pointless.

No, Steph.  It's not for identifying the person.  That statement is asking whether the object is attached to (id).

Edited by Rolig Loon
Link to post
Share on other sites
1 minute ago, Rolig Loon said:

No, Steph.  It's not for identifying the person.  That statement is asking whether the object is attached to (id).

if(id) llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);

This is asking for permission on attatch. That permission will not work when the run time runs. I just tried it does nothing.

Link to post
Share on other sites

Maybe I'm misunderstanding the issue. What I meant was that when you write

    attach(key id)
    {
        if(id) llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
    }

you are requesting permission to animate if the object has just been attached.  You are quite correct that permission will be granted automatically, since you own the object, but you should still be asking.  In this case, putting it in a conditional statement means "request permission if the attach event was triggered because you just attached the object, but don't request it if it was triggered because you detached the object."  That's all I was responding to.  You're not testing to see who attached/detached the object. You just want to be sure that the script only requests permission if the object was just attached.  That's all.

Especially if your script is using llAtttachToAvatarTemp, you actually have to request permissions twice.  The first time, you request PERMISSION_ATTACH.  Then, when the object attaches, you use the snippet above to request PERMISSION_TRIGGER)_ANIMATION.  You can't request them together because ownership changes after you temp attach.

Link to post
Share on other sites
35 minutes ago, Rolig Loon said:

 

Then i can only assume that this, even in in the same parcel cancels the perms.

changed(integer ch)
    {
        if(ch&CHANGED_TELEPORT)
        {
            llSleep(0.5);
            //llRequestPermissions( owner_id, PERMISSION_TRIGGER_ANIMATION );

Edited by steph Arnott
Link to post
Share on other sites

Still not working, I'll let here a more complete code so maybe someone can point me where I'm doing wrong.

My intention is: when person who wears the object clicks "hate" or "love" in response to the HUD, his or her avatar will play an animation. Example: a poke, you can like or hate, and react accordingly (it's more a study, don't take it so seriously as a finished idea of product):

list openChoices = ["Love", "Hate", "-"];
string dialogInfo;
key toucherID;
key ownerID;
integer channelDialog;
integer listenHandle;
integer onoff;
string thaName;
string ownerName;


default {
    attach(key id) {
        if(id) llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
    }
    
    state_entry() {
        // generates a negative non-zero from the last 7 digits of the UUID of the object. Zero = public channel.
        channelDialog = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );
        // set owner of the object
        ownerID = llGetOwner(); 
        ownerName = llKey2Name(ownerID); 
    }

    touch_start(integer num_detected) {            
        // detect toucher id and retrieve uuid, so dialog will be show only to him/her
        toucherID = llDetectedKey(0);
        thaName = llKey2Name(toucherID);
        
        // remove any previous
        llListenRemove(listenHandle);

        // dialog text
        if (toucherID == ownerID) {
            dialogInfo = "\nPokes itself";
        }
        else { // if other person, check profile
            dialogInfo = "\n"+ thaName +" poked itself";
            // show profile
            llInstantMessage(ownerID, "Check profile: secondlife:///app/agent/"+(string)toucherID+"/about");
            // warn 'poker' person is thinking about it
            llInstantMessage(toucherID, "The person is thinking about that...");
        }

        // listen open
        listenHandle = llListen(channelDialog, "", ownerID, ""); 
        // create dialog in that channel
        llDialog(ownerID, dialogInfo, openChoices, channelDialog);
        // setting time limit for response
        llSetTimerEvent(30.0); 
    }

    listen(integer channel, string name, key id, string message) {
        if (message == "-") {
            // in case we reopen the dialog, return now before removing the listener
            llDialog(ownerID, dialogInfo, openChoices, channelDialog);
            return;
        }
        // Turn off listener at a convenient common junction
        llListenRemove(listenHandle);
        // stop timer since the menu was clicked
        llSetTimerEvent(0);

        if (message == "Love") {
            // default message
            llInstantMessage(ownerID, thaName+" poked you and you love it.");
            // other person? Warn
            if (toucherID != ownerID) {
                llInstantMessage(toucherID, "The owner loved it");
            }
        }
        else if (message == "Hate") {
            llInstantMessage(toucherID, "The owner HATED it, don't do it again!");
           
           // I know it's not here, but this is where it must happen, but I have no idea how :)
            run_time_permissions(integer perm) {
                if (perm & PERMISSION_TRIGGER_ANIMATION) {
                    llStartAnimation("Walkpose");
                    llSetTimerEvent(14.0);
                }
            }
        }
        else {
            // do something else.
        }
    }

    timer() {
        llSetTimerEvent(0); // stop timer
        llListenRemove(listenHandle);
        llWhisper(0, "Time out!");
    }   
}

 

Link to post
Share on other sites

The basic concept behind that snippet of code I posted earlier is fairly simple:
"When this HUD is attached to an avatar, request permissions to animate."

Then, at any point later when you would need to play an animation, you can simply call llStartAnimation. 

if (message == "Love") {
    // default message
    llInstantMessage(ownerID, thaName+" poked you and you love it.");
    // other person? Warn
    if (toucherID != ownerID) {
        llInstantMessage(toucherID, "The owner loved it");
    }
    llStartAnimation("love"); // Just play the animation, you have permissions.
}

As for the script you posted, it seems like you don't quite have a hold on "events" as a concept:

else if (message == "Hate") {
    llInstantMessage(toucherID, "The owner HATED it, don't do it again!");
   
    // I know it's not here, but this is where it must happen, but I have no idea how :)
    run_time_permissions(integer perm) {
        if (perm & PERMISSION_TRIGGER_ANIMATION) {
            llStartAnimation("Walkpose");
            llSetTimerEvent(14.0);
        }
    }
}

Events (such as run_time_permissions) cannot be inside of other events (like the listen event in this case). They are separate blocks of code that trigger whenever something happens, like run_time_permissions is triggered after llRequestPermissions if any permissions are granted or denied.

And if you want to only play a love/hate animation after a dialog choice, you don't even need run_time_permissions in the script at all (because permissions are guaranteed to be granted with the method I showed).

Edited by Wulfie Reanimator
Link to post
Share on other sites

Ok, abusing your patience, but I'm really trying to learn it.

In your previous explanation, you told me that:

attach(key id) {
	if(id) llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}

This must be on 'default', so it gives permission for any animation on the attach event, and any time later, right?

Then, "at any point later when you would need to play an animation, you can simply call llStartAnimation".

I tried exactly this right now, same error of "script trying to trigger animations but PERMISSION_TRIGGER_ANIMATION permission not set"...

Link to post
Share on other sites
2 hours ago, Ewadir said:

Ok, abusing your patience, but I'm really trying to learn it.

In your previous explanation, you told me that:


attach(key id) {
	if(id) llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}

This must be on 'default', so it gives permission for any animation on the attach event, and any time later, right?

Then, "at any point later when you would need to play an animation, you can simply call llStartAnimation".

I tried exactly this right now, same error of "script trying to trigger animations but PERMISSION_TRIGGER_ANIMATION permission not set"...

Here's the simplest, complete example I can give:

default
{
    attach(key id)
    {
        if(id) llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
    }

    touch_start(integer n)
    {
        llStartAnimation("holdanimradio");
    }
}

(Of course, you'll have to change "holdanimradio" to something that actually exists in the object.)

You have to make sure that you attach the object after you have saved the script. If you are already wearing the object when you save the script, the "attach" event never triggers, and it won't have permissions until you detach and reattach the object. This demonstrates that:

  1. Permissions to animate are given.
  2. You don't need a run_time_permissions event. (In this example. There are other cases where you would need to use it.)
  3. You can use llStartAnimation without problems.
Edited by Wulfie Reanimator
Link to post
Share on other sites
17 hours ago, Ewadir said:

Hello. I'm creating an item to wear and let other avatars touch you, then user will react with love or hate.

 

I think that your introduction to the problem is not clear. Who needs to be animated with a love/hate animation. The avatar that wears the HUD or the avatar that touches the HUD? Wolfie e.g. answered your question for the case that the avatar wearing the HUD needs to be animated. I understood that the person touching needs to be animated.

Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 606 days.

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

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...