Help with llSetCamersParams
|
|
Locked Semaphore
Registered User
Join date: 26 Oct 2006
Posts: 36
|
03-29-2009 13:44
I am trying to send a message to an attached object and have the camera move to a region position. I get no script or permission errors, the camera just doesn't move. What am I missing? Here is the code fragment: if (cmd == "SETCAM"  { llRequestPermissions(Owner, PERMISSION_CONTROL_CAMERA); vector Pos; Pos.x = llList2Float(l,1); Pos.y = llList2Float(l,2); Pos.z = llList2Float(l,3); llClearCameraParams(); llSetCameraParams([ CAMERA_ACTIVE, TRUE, CAMERA_POSITION_LOCKED, FALSE, ]); llSetCameraParams([ CAMERA_POSITION, Pos, ]); }
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
03-29-2009 14:56
Sorry but you completely missed the way LSL works with requests and events. In this case a an attached event handler will be triggered when the object is attached. In that handler you can make a 'llRequestPermissions( id, PERMISSION_CONTROL_CAMERA ). That will at some point trigger a 'run_time_permissions()' event handler. In that handler you can move your camera. I can only recommend to read the wiki and find some camera examples in the library 
_____________________
From Studio Dora
|
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
03-29-2009 15:30
Dora's right, once the script executes
llRequestPermissions(Owner, PERMISSION_CONTROL_CAMERA);
in your code, it's jumping out of whatever event you have that code in, and looking for code in a runtime_permissions event. Study the llRequestPermissions() function a little closer.
_____________________
My tutes http://www.youtube.com/johanlaurasia
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
03-30-2009 06:59
Well, in this case, not exactly. PERMISSION_CONTROL_CAMERA can only be granted for attached or sat-upon objects, and in those cases is automatically granted upon request, so in fact subsequent calls to clear and set cam parms should execute, even within the requesting code block. This isn't the greatest form, and there are other automatically-granted permissions where this can sometimes fail, and it's all just begging to generate confusion with other permissions the script may be needing, and just generally Not Recommended... but I don't think that's what's going wrong here. Try this hideous kludge: default { touch_start(integer total_number) { llRequestPermissions(llGetOwner(), PERMISSION_CONTROL_CAMERA); llSetCameraParams( [ CAMERA_ACTIVE, TRUE , CAMERA_POSITION_LOCKED, TRUE , CAMERA_POSITION, llGetPos() + <0, 0, 15.0> ] ); llSleep(2.0); llClearCameraParams(); llReleaseCamera(llGetPermissionsKey()); } }
Drop it in a prim, then sit on the prim, use an arrow key to change the default cam position, then touch the prim and watch the cam try to momentarily pop 15m above the prim before settling back down. I'm not sure the whole intent of the script in the OP, so I can't do much to help correct and complete the parameter list, but I doubt moving it to the run_time_permissions() handler will do whatever is desired here.
|
|
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
|
03-30-2009 07:08
You also need to set CAMERA_POSITION_LOCKED to TRUE in most cases, or the system camera will override your camera position instantly.
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
03-30-2009 07:48
From: Qie Niangao ...and in those cases is automatically granted upon request, Even when it is automatically granted it will still generate a 'run_time_permissions' event. It is bad practice not to wait until the run time permission is granted, before you start doing what you need permissions for.
_____________________
From Studio Dora
|
|
Locked Semaphore
Registered User
Join date: 26 Oct 2006
Posts: 36
|
Help with llSetCamersParams Reply to Thread
04-01-2009 12:02
Thank you Yumi, the root of my problems was my misunderstanding of what CAMERA_POSITION_LOCKED actually does.
As a side note, It appears that llRequestPermissions(llGetOwner(), PERMISSION_CONTROL_CAMERA) does NOT generate an event.
llRequestPermissions(llGetOwner(), PERMISSION_TRACK_CAMERA) DOES generate an event, UNLESS combined with a request for an auto-grant permission such as PERMISSION_CONTROL_CAMERA. Go figure.
Thanks to all for your help.
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
04-01-2009 19:44
From: Dora Gustafson Even when it is automatically granted it will still generate a 'run_time_permissions' event. It is bad practice not to wait until the run time permission is granted, before you start doing what you need permissions for. bad form? yes. does it work without conflicts if that's all you're doing in the script? also yes. which is what Qie was saying @ Locked the reason your aren't seeing an event generated is because you don't have an event handler for it. if you have the event handler (runtime_permissions) and it still doesn't show up, I can only guess that you're on no-script land, or the get permissions call isn't being executed for any of a number of possible reasons to do with faulty logic in the code. (like saying 'setcam' when the script expects 'SETCAM' )
_____________________
| | . "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... | - 
|