Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

on_rez issues

Sebastian Lathrop
Registered User
Join date: 15 Jun 2006
Posts: 5
08-07-2006 16:02
I've had some trouble with part of a script I'm working on - the idea is that another object will rez this object with the name Component. When Component is first rezzed, it should request permission from the owner to attach. Upon receiving the permission, it should rename itself and never ask again from there on. However, it seems to request permission to attach every time it is rezzed no matter what it's name is. I've tried other conditions and it seems no matter what it wants to request permission to rez every time. Any ideas? Here is the script...


on_rez(integer start_param)
{
if ( llGetObjectName() == "Component" );
{
llRequestPermissions( llGetOwner(), PERMISSION_ATTACH );
while ( llGetObjectName() == "Component" )
{
integer perm = llGetPermissions();
if (perm & PERMISSION_ATTACH)
{
llOwnerSay ( "Attach permission granted." );
llSetObjectName ( "Ring" );
}

}

}

}
Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
08-07-2006 16:09
From: Sebastian Lathrop
I've had some trouble with part of a script I'm working on - the idea is that another object will rez this object with the name Component. When Component is first rezzed, it should request permission from the owner to attach. Upon receiving the permission, it should rename itself and never ask again from there on. However, it seems to request permission to attach every time it is rezzed no matter what it's name is. I've tried other conditions and it seems no matter what it wants to request permission to rez every time. Any ideas? Here is the script...


on_rez(integer start_param)
{
if ( llGetObjectName() == "Component" );
{
llRequestPermissions( llGetOwner(), PERMISSION_ATTACH );
while ( llGetObjectName() == "Component" )
{
integer perm = llGetPermissions();
if (perm & PERMISSION_ATTACH)
{
llOwnerSay ( "Attach permission granted." );
llSetObjectName ( "Ring" );
}

}

}

}


Bad code!
Make the script wait for the run_time_permissions event to happen, then check you have the permissions, then do the attach. In other words, get rid of your while loop.

The reason why the user has to keep granting the permissions is that the copy in the inventory never has attach permissions granted to it, and your rezzer keeps rezzing this copy.
Gattz Gilman
Banned from RealLife :/
Join date: 29 Feb 2004
Posts: 316
08-07-2006 17:19
also keep in mind that objects renamed with a script that are worn will not keep their name, since they are in your inventory. So lets say you have a ring attached, and the script renames is to Buckle. While its attached its name will stay Buckle, but once you detach and reattach, its name will be back to Ring.

What would be a good idea to do, is get the permission, once its accepted change the name right before you do the attach.
CODE
 
default
{
on_rez(integer param)
{
if(llGetObjectName() == "Component")
{
llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
}
}
run_time_permissions(integer perm)
{
if(perm & PERMISSION_ATTACH)
{
llSetObjectName("Ring");
llAttachToAvatar(ATTACH_LHAND);
}
}
}
_____________________
Sebastian Lathrop
Registered User
Join date: 15 Jun 2006
Posts: 5
08-08-2006 08:30
oh i didn't even know there was a run time permissions event.
well that's much cleaner. thanks!