Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Trouble with permissions

Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
05-03-2007 20:32
I'm working on a flight assist and have run into problems trying to prevent blue window spam everytime someone takes off. the easiest way I can see to do this is to only request permission to track the camera once (since permissions persist between state switches), and only if permission to track the camera hasn't been given.... but it's never requesting permission:

the snippet

CODE

default
{
on_rez(integer num)
{
llResetScript();
}

state_entry()
{
llMessageLinked(LINK_SET, 0, "on", NULL_KEY);
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
if ((llGetPermissions() & PERMISSION_TRACK_CAMERA))
{
}
else
{
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
}
llSetTimerEvent(0.1);
}
}



even using

CODE

if (!(llGetPermissions() & PERMISSION_TRACK_CAMERA))
{
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
}


is resulting in the same thing, no permissions being fired, even though a quick llSay in the loop says that it's evalutating the way I expect it should.

[edit]

I managed to hack this solution from the example given in the library, but for some reason the logic gate seems backwards to me. I'd have thought this would work for a != argument. To me this reads as "If permissions for camera and controls have already been given, request permissions for camera and controls"

CODE

if ((llGetPermissions() & PERMISSION_TRACK_CAMERA|PERMISSION_TAKE_CONTROLS) == PERMISSION_TRACK_CAMERA|PERMISSION_TAKE_CONTROLS)
{
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS|PERMISSION_TRACK_CAMERA);

}
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
05-04-2007 01:10
llRequestPermissions triggers a run_time_permissions Event and the best place to handle that event is in the run_time_permissions Event Handler. :D

Not entirely sure what you're trying to do but I'd expect to see something like this:

default
CODE
{
state_entry()
{
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_TRACK_CAMERA);
}

run_time_permissions(integer perm)
{
if (perm & PERMISSION_TAKE_CONTROLS)
{
// got controls
}

if (perm & PERMISSION_TRACK_CAMERA)
{
// got camera
}
}
}
Also make sure to get all the permissions in one hit:

From: LSL Wikki
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.
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
05-04-2007 01:15
From: Pale Spectre
llRequestPermissions triggers a run_time_permissions Event and the best place to handle that event is in the run_time_permissions Event Handler. :D

Not entirely sure what you're trying to do but I'd expect to see something like this:

default
CODE
{
state_entry()
{
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_TRACK_CAMERA);
}

run_time_permissions(integer perm)
{
if (perm & PERMISSION_TAKE_CONTROLS)
{
// got controls
}

if (perm & PERMISSION_TRACK_CAMERA)
{
// got camera
}
}
}
Also make sure to get all the permissions in one hit:


I'm using state changes so I needed a hack to get around having it ask for a new set of permissions every change back to the previous state, which happens fairly frequently. Originally I did it the way you suggested and it resulted in blue-box spam, which is why I was looking for a work-around.
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-04-2007 01:36
Not sure if this is appliciable in your system, but I usually use state default to perform any one time initialisation and grab any permissions etc and then switch to a primary/running state when that has completed.