Difference between revisions of "User:Ezian Ecksol"

From Second Life Wiki
Jump to navigation Jump to search
Line 1: Line 1:
<nowiki>integer chan = 1;
'''Cam Lock/Follow'''
<lsl>
// (c) Ezian Ecksol. Use, modify as you like.
//
// Put script into prim, attach it.
// Position your cam as you like.  Say
// '/1 camstyle follow' to lock the cam, but let it follow you AV
// '/1 camstyle lock' to lock the cam completly
// '/1 camstyle' to release cam again.
 
integer chan = 1;


key owner;
key owner;
Line 41: Line 51:
default
default
{
{
     state_entry()
     state_entry() {
    {
         owner = llGetOwner();
         owner = llGetOwner();
         llListen(chan, "", owner, "");
         llListen(chan, "", owner, "");
     }
     }
      
      
Line 59: Line 64:
     }
     }


   
     changed(integer c) {
     changed(integer c) {
         if (c & CHANGED_OWNER)
         if (c & CHANGED_OWNER)
Line 66: Line 69:
     }
     }
}
}
</nowiki>
</lsl>

Revision as of 09:59, 18 September 2008

Cam Lock/Follow <lsl> // (c) Ezian Ecksol. Use, modify as you like. // // Put script into prim, attach it. // Position your cam as you like. Say // '/1 camstyle follow' to lock the cam, but let it follow you AV // '/1 camstyle lock' to lock the cam completly // '/1 camstyle' to release cam again.

integer chan = 1;

key owner; list keywords = ["lock", "follow"];

cam_style(integer cs) {

   llRequestPermissions(owner, PERMISSION_CONTROL_CAMERA | PERMISSION_TRACK_CAMERA);
   llClearCameraParams(); 
       
   if (!cs)
       return;
       
   vector cpos = llGetCameraPos();
   list params = [CAMERA_ACTIVE, TRUE, CAMERA_POSITION_LOCKED, TRUE, CAMERA_POSITION_THRESHOLD, 0.5,
                   CAMERA_FOCUS_THRESHOLD, 0.5, CAMERA_POSITION, cpos];
       
   if (cs == 1) 
       params += [
           CAMERA_DISTANCE, .5, // ( 0.5 to 10) meters
           CAMERA_BEHINDNESS_LAG, 0.1, // (0 to 3) seconds
           CAMERA_PITCH, 10.0, // (-45 to 80) degrees
           CAMERA_FOCUS, cpos + llRot2Fwd(llGetCameraRot()), // region-relative position
           CAMERA_FOCUS_LAG, 0.1, // (0 to 3) seconds
           CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)
           CAMERA_POSITION_LAG, 1.0 // (0 to 3) seconds
       ];
       
   else if (cs == 2) 
       params += [
           CAMERA_FOCUS_LAG, 0.0, // (0 to 3) seconds
           CAMERA_BEHINDNESS_LAG, 0.5 // (0 to 3) seconds
       ];
       
   llSetCameraParams(params);

}


default {

   state_entry() {
       owner = llGetOwner();
       llListen(chan, "", owner, "");
   }
   
   listen(integer channel, string name, key id, string msg) {
       msg = llToLower(msg);
       list m = llParseString2List(msg, [" "], []);
       
       if (llList2String(m, 0) == "camstyle") 
           cam_style(llListFindList(keywords, [llList2String(m, 1)]) + 1);
   }
   changed(integer c) {
       if (c & CHANGED_OWNER)
           llResetScript();
   }

} </lsl>