Jump to content

Permission Errors


Yurtiel
 Share

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

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

Recommended Posts

default
{
    changed(integer change)
    {
        if(change & CHANGED_OWNER)
        {
            llResetScript();
        }
    }
    
    state_entry()
    {
        owner = llGetOwner();
        llRequestPermissions(owner, PERMISSION_TRIGGER_ANIMATION);
    }
    
    run_time_permissions(integer perm)
    {
        if(perm & PERMISSION_TRIGGER_ANIMATION)
        {
            llSay(0, "Mmmm! Refreshing!");
            integer cnt = 0;
            for(cnt = cnt; cnt <= cnt; ++cnt)
            {
            llStartAnimation(anim);
            llSleep(1.0);
            llPlaySound(sound, 0.5);
            llSleep(3.0);
            llStopSound();
            }      
        }
    }
}

 For some stupid reason this script absolutely refuses tow ork no matter how I do it, I've worked on it for about an hour now with absolutely no progress. This is the final result and it's one that should work, but for some reason it doesn't.

Whenever I wear the object this script is in, the object works fine, it plays the animation, plays the sound, doesn't give me any permission errors what so ever.

Whenever I give it to anyone else however it starts to give them script errors, I noticed it's because I wasn't having the object update when it got a new owner, so I decided to have it reset when it changed owners.

Originally the script was made with an attach() command but after reset the person would have to reattach it for it to work as it should which is a hassle I would like to prevent the customer from having.

So in my bid I sought to just make it play the animation and sound through a start_entry() block where the wearer of the attached prim could just give it permissions manually which is much less of a hassle, however for some reason the script seems intent to not do this and instead start screaming out PERMISSION_TRIGGER_ANIMATION permission not given errors at the wearer for as long as it's attached and the loop is executing.

This has frustrated me so much that I'm at the point I want to break something, and it's something I've done in prims thousands of times before in a similiar fashion. Does anyone know why this absolutely refuses to work now?

Link to comment
Share on other sites

I assume that you just didn't copy/paste the global variables that are at the top of your script when you posted it here, right?  You should have

key owner;

string anim = "name_of_my_anim_goes_here";

string sound = "name_of_my_sound_goes_here";

If your object is always meant to be worn, however, you should never need to use your changed event.  After all, by definition the person who is wearing the object must be the owner.  I'm assuming that your odd for loop is intended to keep the sequence of sound and animation going on indefinitely, so if I were writing this script, I might try

string anim = "anim";string sound = "sound";integer cnt;default{	attach(key id)	{		if (id)		{			llSetTimerEvent(0.0);			cnt = 0;			llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);		}                else                {                        llSetTimerEvent(0.0);                }	}	run_time_permissions(integer perm)	{		if(perm & PERMISSION_TRIGGER_ANIMATION)		{			llSay(0, "Mmmm! Refreshing!");			llStartAnimation(anim);			llSetTimerEvent(1.0);		}	}	timer()	{		cnt = (++cnt)%5;		if (cnt == 0)		{			llPlaySound(sound, 0.5);		}		else if (cnt == 4)		{			llStopSound();			llStartAnimation(anim);		}	}} 

 

EDIT:  Ooops.  Forgot to turn the timer off.

 

Link to comment
Share on other sites

Thanks Rolig, Once again you've helped me greatly.

If I may though, is there any reason it was expecting me to reset it every time to use the for loop in it?

Originally I had it set so that it didn't have a changed state and used the for loop and the loop was only supposed to activate if they attached it and they were the owner.

Link to comment
Share on other sites


Yurtiel wrote:

If I may though, is there any reason it was expecting me to reset it every time to use the for loop in it?

The for loop you made will loop forever and keep the script busy

That means the script can do nothing else until it is reset

The loop will never stop because cnt will always equal cnt, cnt is identical to itself

:smileysurprised::):smileyvery-happy:

Link to comment
Share on other sites

Dora's got it.  Said a different way, you can't interrupt an event.  You can provide a path for leaving an event when specific internal conditions are met with an if test, for example, but you can't force an event to stop from the outside.  The only way to stop an infinite loop like the one you created is to reset the whole script.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3481 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...