Jump to content

2 permissions on attach


XbabylonX
 Share

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

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

Recommended Posts

Hello,

recently Im trying to create a hud which asks for 2 different permissions.

I used the following

    on_rez(integer start)
    {
    llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
    llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);   
    }

When the hud is attached, it asks me only for the debit permissions which I accept.

The crazy thing folows then: Im clicking a button to pay myself (and animate me) and then the script tells me "Script trying to debit L$ from owner but PERMISSION_DEBIT permission not set!" but myself is animated :matte-motes-confused:

Isnt crazy?

 

PS I tried to put the requested permissions in state entry or attached, they never work.

Link to comment
Share on other sites

Crazy? Not so much. :matte-motes-tongue:

You first request debit perms for which you get the dialog.

Then you request perms a second time, which overwrites the first permission request.

The correct function call looks like this:

llRequestPermissions(llGetOwner(), PERMISSION_DEBIT | PERMISSION_TRIGGER_ANIMATION);
  • Like 1
Link to comment
Share on other sites

From the LSL wiki:

Permissions do not accumulate.

  • If a permission was requested with a previous call to this function and granted, then in subsequent call was not requested, that permission is released (lost).
  • To request two or more permissions at the same time, use the bitwise OR (|) operator, e.g.:
    llRequestPermissions(AvatarID, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION)
  • Like 1
Link to comment
Share on other sites

It still goes crazy.

You guys what you suggested me was right, both actions, pay and animate, are working now but I keep getting the warning window keeps popping up "Script trying to stop animations but PERMISSION_TRIGGER_ANIMATION permission not set" :matte-motes-confused:

Link to comment
Share on other sites


XbabylonX wrote:

It still goes crazy.

You guys what you suggested me was right, both actions, pay and animate, are working now but I keep getting the warning window keeps popping up
"Script trying to stop animations but PERMISSION_TRIGGER_ANIMATION permission not set"
 :matte-motes-confused:

That's a common enough scripting error. Somewhere in the script there's a call to llStopAnimation() that occurs before PERMISSION_TRIGGER_ANIMATION is obtained or after that permission is lost. Without seeing the whole script it's impossible to tell whether the call is even necessary, or if this is hinting at bigger problems, or if you just need to guard the llStopAnimation() call with tests of llGetPermissions() and llGetPermissionsKey().

  • Like 1
Link to comment
Share on other sites

You are absolutelly right, there is a llStopAnimation command but its inside a ELSE condition

    link_message(integer sender_num, integer num, string str, key id)    {        if(str!="-1")        {                    Amount=(integer)llList2String(Amounts,(integer)str);        Animation=llList2String(Animations,(integer)str);        llGiveMoney(PayTo, Amount);        llStartAnimation((string)Animation);        }        else        {        llStopAnimation((string)Animation);        }    }

 I use link_message because I have linked 2 buttons with the root prim, the first starts the anim and the second stops it.

Link to comment
Share on other sites

And I'm going to guess that the link message is received after the person has stood up from or detached the sending object.  For example, the following changed event will generate that same error message...

changed (integer change){    if (change& CHANGED_LINK)    {        if (llAvatarOnSitTarget() && (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION))        {            llStartAnimation("new_anim");        }        else    // Ooops!  llAvatarOnSitTarget() == NULL_KEY        {            llStopAnimation("new_anim");    // Command will fail        }    }}
  • Like 1
Link to comment
Share on other sites


XbabylonX wrote:

 I use link_message because I have linked 2 buttons with the root prim, the first starts the anim and the second stops it.

Best to avoid that and use as few scripts as possible in as few prims as possible. Several ways to do that, but start with llDetectedLinkNumber() which is illustrated in the following silly script:

string anim = "sit";default{    touch_start(integer total_number)    {        string touchedLinkName = llGetLinkName((0));        if ("Button 2" == touchedLinkName)        {                        else                llOwnerSay("Tested first, else llStopAnimation() would err here.");        }        else        {            llOwnerSay("touched something else");            // Totally unrealistic, but need it somewhere in example, so get permissions here            llRequestPermissions(llDetectedKey(0), PERMISSION_DEBIT | PERMISSION_TRIGGER_ANIMATION);        }    }    run_time_permissions(integer perms)    {        if (PERMISSION_TRIGGER_ANIMATION & perms)            llStartAnimation(anim);    }}

See also the red-highlighted code as a "guard" of llStopAnimation(). Because you're (intending to) deal with an attachment only, you may be able to simplify that logic some, but it's not going to burn much CPU to leave it as-is, either.

  • Like 1
Link to comment
Share on other sites


XbabylonX wrote:

If this piece of code is placed inside the link root, then I cant use it because I dont use touch triggers in it.

No, I'm saying that you should use touch triggers in root, and only there; i.e., any scripts in any child prims should be removed and the logic grafted into that single script in the root. I could be convinced otherwise if the object has a whole lot of surface area that shouldn't be touchable and would be confusing to have see the "touch" pointer when the mouse hovers over it.

Anyway, having a couple extra scripts doesn't matter that much, as long as there's no confusion about which script is doing what. And that makes me wonder: are you sure there's no script anywhere in the object where an llStopAnimation call is still running, not yet commented out? Without that call, I don't know how you could get that particular error.

  • Like 1
Link to comment
Share on other sites

:matte-motes-crying: Absolutelly my mistake. Yes, I forgot that I included the llstopanimation in the rest of the linked prims, and was the reason I kept getting the warning window :matte-motes-dont-cry:

Now the problem is gone, works as it should.

Thank you all for your time and contribution!

Link to comment
Share on other sites

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