Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Service tray script

Petteri Yiyuan
Registered User
Join date: 4 Mar 2007
Posts: 56
06-08-2009 04:12
I have made tray with items to serve and carry around. I have now problem as i have two scripts on it. When owner of object uses menu to control animation all avatars who has same object (they are wearing object as they are using it) gets controlled by same animation). I know there is problem or owner permission missing but cant figure it out (as still learning scripting)

CODE

//script to carry tray in carry pose
string anim ="drink";
string anim2 ="boxcarry";

default
{
attach(key victim)
{
if(victim == NULL_KEY)
{
llStopAnimation(anim2);
llStopAnimation(anim2);
llSetTimerEvent(0);

}
else
{
llRequestPermissions(victim,PERMISSION_TRIGGER_ANIMATION);
}
}

run_time_permissions(integer permissions)
{
if (PERMISSION_TRIGGER_ANIMATION & permissions)
{
llStartAnimation(anim2);
llStartAnimation(anim2);

llSetTimerEvent(15);
}
}

timer()
{
llStartAnimation(anim2);
llStartAnimation(anim2);
}

}


CODE

//script to bring up menu dialog and launch serving animation
integer COMMAND_CHANNEL = 11;
string CurrentAnimation = "";
integer PermGranted=FALSE;
list Animaties = [ "carry", "serve"] ;

StartAnimatie(key id, string anim)
{
CurrentAnimation = anim;
if (!PermGranted)
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}

default

{
state_entry()
{
llListen(COMMAND_CHANNEL, "", NULL_KEY, "" );
}
listen( integer chan, string name, key id, string msg )
{
integer index;
if (msg == "menu" )
{
llDialog(llGetOwner(), "Choose your animation:", ["carry", "serve"], COMMAND_CHANNEL);
}
index = llListFindList(Animaties, [ llToLower(msg) ]);

if (CurrentAnimation != "")
{
llStopAnimation(CurrentAnimation);
}
if (index != -1)
{
PermGranted = FALSE; // ask permission
StartAnimatie(id, llList2String(Animaties, index));
}
}

touch_start(integer total_number)
{
llGiveInventory(llDetectedKey(0), "Black Wine cup");
}

run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
PermGranted = TRUE;
llStartAnimation(CurrentAnimation);
}
}
}
Lynnore Vaher
Registered User
Join date: 19 Jul 2008
Posts: 16
06-08-2009 05:34
Set the listen to only listen to the owner of the object

CODE
llListen(COMMAND_CHANNEL, "", llGetOwner(), "" ); 
Petteri Yiyuan
Registered User
Join date: 4 Mar 2007
Posts: 56
06-08-2009 06:23
From: Lynnore Vaher
Set the listen to only listen to the owner of the object

CODE
llListen(COMMAND_CHANNEL, "", llGetOwner(), "" ); 

Hmm it still does same. Animates all other avies also using same object
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
06-08-2009 07:25
If you are not still the owner of the units that other people are wearing, they should not respond to you once the llListen filter is set to listen only to llGetOwner(). Since that's not working, it sounds like the other units think you still own them. Try putting in a changed event .....

CODE

changed (integer change)
{
if (change & CHANGED_OWNER)
{
llResetScript();
}
}


That should force it to recognize the change in ownership. Since you don't have any other configuration data saved, a reset won't lose anything.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Petteri Yiyuan
Registered User
Join date: 4 Mar 2007
Posts: 56
06-08-2009 07:36
Well that worked. Thanks a lot
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-08-2009 09:40
yeah once a listen is started it's locked to what it was started with... so to get it to recognize someone else, you have to kill the old listen and start a new one...

in the first scenario it was checking it's current owner, and then saying, listen only to this person... which is bad if it changes owners, because it's still listening to the same person, and needs to be updated.

or to explain it a different way... llGetOwner only gives the owner when it is called, if that later changes, it has to be called again to get the (now) current owner.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -