Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

how to get this permission right

Varun Blitz
Registered User
Join date: 22 May 2008
Posts: 62
07-11-2008 03:56
i have made a tool which needs to be attached to avatar and only then further action can take place
what i was doing was that i was rezzing it from another inventory and then in state_entry it asks for attach permission. i wanted that if user says no then it shud again ask for the same till it's granted that permission.
what is happening in my system is that the script runs wild and asks for permission repeatedly and gives my say 100 boxes asking for that procedure.
how shud i achieve the thing i need.
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
07-11-2008 04:03
From: Varun Blitz
how shud i achieve the thing i need.
Step 1: Post your code.
Varun Blitz
Registered User
Join date: 22 May 2008
Posts: 62
07-11-2008 04:24
state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);
llOwnerSay("Waiting for user permission ";);
flag=0;

check_permission=llGetPermissions();
do
{
if(check_permission & PERMISSION_ATTACH)
{
flag=1;
llAttachToAvatar(attach_position);
//Time to attach tool
llSleep(1.0);
llOwnerSay("TOOL ATTACHED";);
llShout(TOOL_CHANNEL,"attached";);
}
else
{
//llShout(AUTO_BUG_CHANNEL,"Permission to attach object is not set. Check tool's script";);
llOwnerSay("Permission to attach object is not set. Check tool's script.";);
}
}while(flag==0);
}
Varun Blitz
Registered User
Join date: 22 May 2008
Posts: 62
07-11-2008 04:39
From: Varun Blitz
state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);
llOwnerSay("Waiting for user permission ";);
flag=0;

check_permission=llGetPermissions();
do
{
if(check_permission & PERMISSION_ATTACH)
{
flag=1;
llAttachToAvatar(attach_position);
//Time to attach tool
llSleep(1.0);
llOwnerSay("TOOL ATTACHED";);
llShout(TOOL_CHANNEL,"attached";);
}
else
{
//llShout(AUTO_BUG_CHANNEL,"Permission to attach object is not set. Check tool's script";);
llOwnerSay("Permission to attach object is not set. Check tool's script.";);
}
}while(flag==0);
}



now i have changed the thing and asking the permission again in run_time_permissions
i think i got it right this time.
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
07-11-2008 11:04
You are (were?) getting constant permission requests because you don't wait for the user to respond. Basically, take everything inside the do/while loop, and move it to a run_time_permissions event handler, and instead of using llGetPermissions, just use the permissions parameter passed to the handler.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
07-11-2008 21:38
Quite. And if you want it to ask for permissions again when it is rezzed (if it doesn't have them already), put another request in an 'on_rez' event handler instead of looping endlessly.