Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Why does this generate an error and works?

Owner Maltese
Registered User
Join date: 13 Sep 2005
Posts: 65
06-07-2007 09:20
The script below works. The bag of chips are rezzed invisible, it asks permission to attach and animate, becomes visible, attaches to the left hand and the avi eats for 10 to 20 seconds.

Why then does it generate a not attached error when it works perfectly and does attach? The only thing that does not happen is that the llSetObject does not change the name of the item so that the user can identify it and delete it.

Is this one of those famous SL gliches?

Thanks

integer AviEating;
default
{
state_entry()
{
AviEating = FALSE;
}

on_rez(integer start_param)
{
if (AviEating == FALSE)
{
llSetAlpha(0,ALL_SIDES);
llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
llOwnerSay("Delete this - please don't litter.";);
llDie();
}

}

run_time_permissions(integer perm)
{
if (perm==PERMISSION_ATTACH);
{
llSetAlpha(1,ALL_SIDES);
llAttachToAvatar(ATTACH_LHAND);
llSleep(2);
}
if (perm==PERMISSION_TRIGGER_ANIMATION)
{
llSetTimerEvent(llFrand(10)+ 10);
llStartAnimation("Eat Popcorn";);
}
}

timer()
{
llStopAnimation("Eat";);
llSetObjectName("Empty bag of chips";);
AviEating=TRUE;
llDetachFromAvatar();
}
}
_____________________
The only interactive virtual drug in Second Life. Come on down to the Seclimine Shack on Seclimine Street and try it out.
Seclimine: Helping you lead the way.....
Http://www.Seclimine.com Zeuzara 229, 104, 113
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
06-07-2007 09:27
You've got a stray ; at the end of your if statement here..
CODE

run_time_permissions(integer perm)
{
if (perm==PERMISSION_ATTACH);
{
llSetAlpha(1,ALL_SIDES);
llAttachToAvatar(ATTACH_LHAND);
llSleep(2);
}
if (perm==PERMISSION_TRIGGER_ANIMATION)
{
llSetTimerEvent(llFrand(10)+ 10);
llStartAnimation("Eat Popcorn");
}
}


Also, the run_time_permissions event gives you a bit mask - not a single value. I think you want to do something like this instead...

CODE

run_time_permissions(integer mask)
{
if (mask & PERMISSION_ATTACH)
{
llSetAlpha(1,ALL_SIDES);
llAttachToAvatar(ATTACH_LHAND);
llSleep(2);
}

if (mask & PERMISSION_TRIGGER_ANIMATION)
{
llSetTimerEvent(llFrand(10)+ 10);
llStartAnimation("Eat Popcorn");
}
}

Haven't done too much here before but you might also have to keep globals around to remember if you've already started the animation or done the attachment.. Dunno if the event will just fire once or if you'll get serveral of them.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
06-07-2007 09:28
From: The Wiki
Be aware that the effects of this call are not additive. This means that all desired permissions must be requested for any call because the new permissions (or lack thereof) will completely replace the old permissions. Requesting permission FALSE (or 0) will result in all permissions being released and will not raise the run_time_permissions event handler.


Thus, when you request the ANIMATE permission, you are releasing the ATTACH permission.

Either request them both initially, or request them both in the second request.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
06-07-2007 09:36
Yeah, what Talarus said, too.

To answer the original question, I think it's the extra ; in there. The code below that will always execute, regardless of if it's gotten the permission yet..
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Owner Maltese
Registered User
Join date: 13 Sep 2005
Posts: 65
06-07-2007 09:46
From: someone
Thus, when you request the ANIMATE permission, you are releasing the ATTACH permission.

Either request them both initially, or request them both in the second request


Okay, Thanks. :-) Now, I get that the animation permission replaces the attach permission (didn't realize that before), but I don't get what you mean by requesting them both intially or both on the second request?

Should I request the animation first then within the run time permission state request the attach?

Sorry for being dense on this.

Thanks for the help.
_____________________
The only interactive virtual drug in Second Life. Come on down to the Seclimine Shack on Seclimine Street and try it out.
Seclimine: Helping you lead the way.....
Http://www.Seclimine.com Zeuzara 229, 104, 113
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
06-07-2007 09:50
Instead of this...
CODE

llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);

...do this...
CODE

llRequestPermissions(llGetOwner(), PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);



/me misses the php bbcode tags and hopes they come back soon.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
06-07-2007 09:54
In your original script, you make two requests.

Option 1: Request them both initially

CODE

llRequestPermissions(llGetOwner(), PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);


Option 2: Request them both the second time

CODE

llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
llRequestPermissions(llGetOwner(), PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);


Detaching also doesn't trigger the on_rez event handler, which creates an interesting situation. You force the av to litter when done eating, and only admonish them if they pick up the empty bag and re-rez it. Why not just llDie() automatically a few seconds after they drop the bag? Self-cleaning litter! :D
Owner Maltese
Registered User
Join date: 13 Sep 2005
Posts: 65
06-07-2007 09:57
*Light dawns* *A heavenly chior sings "ahh" in unison*

Thank you. Now I get it completely. :-)

About the llDie() thing, I was following the wiki which said I couldn't do what you suggested.... or did I read that wrong as well (which is something I do very well...)? :-)

From: someone
/me misses the php bbcode tags and hopes they come back soon.


*nods quickly in agreement*
_____________________
The only interactive virtual drug in Second Life. Come on down to the Seclimine Shack on Seclimine Street and try it out.
Seclimine: Helping you lead the way.....
Http://www.Seclimine.com Zeuzara 229, 104, 113
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
06-07-2007 15:09
From: Owner Maltese
*Light dawns* *A heavenly chior sings "ahh" in unison*

Thank you. Now I get it completely. :-)

About the llDie() thing, I was following the wiki which said I couldn't do what you suggested.... or did I read that wrong as well (which is something I do very well...)? :-)



*nods quickly in agreement*



You cannot llDie an attachment, but once its dettached you can.
_____________________
I'm back......