Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Permissions?

Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
09-30-2007 10:06
got a chair, want it to hear a key and send siter's cam to the target.

says it's getting the permisions, debugging, and says target, but cam not moving... wht am i missing?

CODE


key metarget;
integer look=0;
integer CAMCHAN = -61;
vector target;
list pos;
default
{
state_entry()
{


llListen(CAMCHAN,"",NULL_KEY,"");
}

changed(integer change)
{
if(change==CHANGED_LINK )
{
key avatar = llAvatarOnSitTarget();

if(avatar!=NULL_KEY)
{
llListen(CAMCHAN,"",NULL_KEY,"");
llRequestPermissions(avatar,PERMISSION_CONTROL_CAMERA);
llSay(0,llKey2Name(avatar)+"; "+llKey2Name(llGetPermissionsKey()));
}
if(avatar==NULL_KEY)
{
look=0;
llSetTimerEvent(0);
}
}
}

run_time_permissions(integer perm)
{
if (perm==PERMISSION_CONTROL_CAMERA)
{
llSay(0,"perm");
llListen(CAMCHAN,"",NULL_KEY,"");
llSetTimerEvent(1);
}
}

listen(integer chan,string nam,key id,string msg)
{
if (msg!="")
{
// llSay(0,msg);
look=1;
metarget=(key)msg;
llSay(0,(string)metarget);
pos=llGetObjectDetails(metarget,[OBJECT_POS]);
target=llList2Vector(pos,0);
llSay(0,(string)target);
llSetCameraParams([CAMERA_FOCUS,target]);

//llSetTimerEvent(1);
}
}
timer()
{

pos=llGetObjectDetails((key)metarget,[OBJECT_POS]);
target=llList2Vector(pos,0);
llSetCameraParams([CAMERA_POSITION,target+<1,1,1>,CAMERA_FOCUS,target,CAMERA_DISTANCE,3.0]);
//llSay(0,(string)target);


}
}


Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
09-30-2007 10:43
hehe had forgotten to put ACTIVE TRUE...

but still can't get it to release without throwing an error...

here's what it looks like now:

CODE

key metarget;
integer look=0;
integer CAMCHAN = -61;
vector target;
list pos;
key avatar;
vector face;
giveback()
{
llSetCameraParams([CAMERA_ACTIVE,FALSE,CAMERA_FOCUS_LOCKED,FALSE,CAMERA_POSITION_LOCKED,FALSE]);
llSetTimerEvent(0);
llListenRemove(CAMCHAN);
}


default
{
state_entry()
{

giveback();
llListen(CAMCHAN,"",NULL_KEY,"");
}

changed(integer change)
{
if(change==CHANGED_LINK )
{
avatar = llAvatarOnSitTarget();

if(avatar!=NULL_KEY)
{
llListen(CAMCHAN,"",NULL_KEY,"");
llRequestPermissions(avatar,PERMISSION_CONTROL_CAMERA);
llSay(0,llKey2Name(avatar)+"; "+llKey2Name(llGetPermissionsKey()));
}
if(avatar==NULL_KEY)
{
look=0;


giveback();

avatar=NULL_KEY;
}
}
}

run_time_permissions(integer perm)
{
if (perm==PERMISSION_CONTROL_CAMERA)
{
if(avatar!=NULL_KEY)
{
llSay(0,"perm");
llListen(CAMCHAN,"",NULL_KEY,"");
llSetTimerEvent(1);
}
if(avatar==NULL_KEY)
{
look=0;
llSetTimerEvent(0);

giveback();
target = llGetPos();
llListenRemove(CAMCHAN);

avatar=NULL_KEY;
}
}
}

listen(integer chan,string nam,key id,string msg)
{
if (msg!="")
{
if(avatar!=NULL_KEY)
{

look=1;
metarget=(key)msg;
llSay(0,(string)metarget);
pos=llGetObjectDetails(metarget,[OBJECT_POS,OBJECT_ROT]);
target=llList2Vector(pos,0);
face=3*llRot2Fwd(llList2Rot(pos,1));
llSay(0,(string)target);
llSetCameraParams([CAMERA_ACTIVE,TRUE,CAMERA_POSITION,target+face,CAMERA_FOCUS,target,CAMERA_FOCUS_LOCKED,TRUE,CAMERA_POSITION_LOCKED,TRUE]);
llSetTimerEvent(1);
}
else
{
// giveback();
target = llGetPos();


}
}
}
timer()
{
if(avatar!=NULL_KEY)
{
if (look==1)
{
pos=llGetObjectDetails((key)metarget,[OBJECT_POS]);
target=llList2Vector(pos,0);
llSetCameraParams([CAMERA_ACTIVE,TRUE,CAMERA_POSITION,target+face,CAMERA_FOCUS,target,CAMERA_FOCUS_LOCKED,TRUE,CAMERA_POSITION_LOCKED,TRUE]);

}
}
else
{
giveback();
target = llGetPos();
}
}
}
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
10-01-2007 08:26
heyas;

first, check the wiki about permissions and change. those should be using bitwise & checks not == checks.


if it is an attachment, i believe there's a bug in the jira where camera permissions do not work on attachments. ah, but you are sitting on it. hmm...


if you sit on it and hit escape or the arrow keys, does the camera move. sometimes the camera is locked in a spot where the user put it and doesnt jump into position right away.


but, if it is throwing an error like 'trying to blah blah but permissions not set'....

im not sure. if the above & bit doesnt work... does the error happen on script reset? the first thing you're doing is giveback(), which is trying to control the camera before you give camera permissions. i think.

wiser scripters than me should know more.
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705
Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
10-01-2007 16:09
thank you!

and double-duh, i did away with the whole giveback routine and just had it reset script on unsit.

permissions get me so paranoid lol