Difference between revisions of "LlRotTarget"

From Second Life Wiki
Jump to navigation Jump to search
Line 9: Line 9:
|caveats
|caveats
|constants
|constants
|examples=<pre>
|examples=<pre>vector standrot = <0.0, 0.0, 0.0>;
 
 
vector standrot = <0.0, 0.0, 0.0>;
vector fliprot = <45.0, 0.0, 0.0>;
vector fliprot = <45.0, 0.0, 0.0>;


Line 25: Line 22:
{
{


state_entry(){  
    state_entry(){  
 
        rottarget = llRotTarget(llEuler2Rot(fliprot*DEG_TO_RAD), 0.1);
    rottarget = llRotTarget(llEuler2Rot(fliprot*DEG_TO_RAD), 0.1);
        llSetPrimitiveParams ([PRIM_ROTATION, llEuler2Rot(standrot*DEG_TO_RAD)]); // rotate to standrot
 
    }
    llSetPrimitiveParams ([PRIM_ROTATION, llEuler2Rot(standrot*DEG_TO_RAD)]); // rotate to standrot
 
}


     not_at_rot_target()
     not_at_rot_target()
Line 39: Line 33:
         }
         }
          
          
touch_start (integer total_number)  
    touch_start (integer total_number){
 
        state rotatestate; // change to state for new position
    {
 
    state rotatestate; // change to state for new position
 
     }
     }
   
}
}
              
              
        
        
    state rotatestate  
state rotatestate
   
{  
    {  
     state_entry(){  
     state_entry(){  
    rottarget = llRotTarget(llEuler2Rot(fliprot*DEG_TO_RAD), 0.1);
        rottarget = llRotTarget(llEuler2Rot(fliprot*DEG_TO_RAD), 0.1);
    llSetPrimitiveParams ([PRIM_ROTATION, llEuler2Rot(fliprot*DEG_TO_RAD)]); // rotate to new point
        llSetPrimitiveParams ([PRIM_ROTATION, llEuler2Rot(fliprot*DEG_TO_RAD)]); // rotate to new point
     }
     }
      
      
     at_rot_target(integer tnum, rotation targetrot, rotation ourrot)
     at_rot_target(integer tnum, rotation targetrot, rotation ourrot){  
        {  
         llRotTargetRemove( rottarget );
         llRotTargetRemove( rottarget );
         llOwnerSay("there"); //reached the target
         llOwnerSay("there"); //reached the target
        }
    }


     touch_start(integer touched)
     touch_start(integer touched){  
   
    {  
         state default;  
         state default;  
     }
     }
Line 72: Line 57:
}
}


</pre><pre>
</pre>
 
<pre>vector standrot = <0.0, 0.0, 0.0>;
vector standrot = <0.0, 0.0, 0.0>;
vector fliprot = <45.0, 0.0, 0.0>;
vector fliprot = <45.0, 0.0, 0.0>;


Line 87: Line 71:
{
{


state_entry(){  
    state_entry(){  
 
        rottarget = llRotTarget(llEuler2Rot(fliprot*DEG_TO_RAD), 0.1);
    rottarget = llRotTarget(llEuler2Rot(fliprot*DEG_TO_RAD), 0.1);
        llSetPrimitiveParams ([PRIM_ROTATION, llEuler2Rot(standrot*DEG_TO_RAD)]); // rotate to starting point
 
    }
    llSetPrimitiveParams ([PRIM_ROTATION, llEuler2Rot(standrot*DEG_TO_RAD)]); // rotate to starting point
 
}


     not_at_rot_target()
     not_at_rot_target()
        {  
    {  
         llRotTargetRemove( rottarget );
         llRotTargetRemove( rottarget );
         llOwnerSay("not there"); //not at target
         llOwnerSay("not there"); //not at target
        }
    }
          
          
touch_start (integer total_number)  
    touch_start (integer total_number)
 
     {
     {
 
        state rotatestate; // change to state for new position
    state rotatestate; // change to state for new position
 
     }
     }
   
}
}
              
              
        
        
    state rotatestate  
state rotatestate  
   
{  
    {  
     state_entry(){  
     state_entry(){  
    rottarget = llRotTarget(llEuler2Rot(fliprot*DEG_TO_RAD), 0.1);
        rottarget = llRotTarget(llEuler2Rot(fliprot*DEG_TO_RAD), 0.1);
    llSetPrimitiveParams ([PRIM_ROTATION, llEuler2Rot(fliprot*DEG_TO_RAD)]); // rotate to new point
        llSetPrimitiveParams ([PRIM_ROTATION, llEuler2Rot(fliprot*DEG_TO_RAD)]); // rotate to new point
     }
     }
      
      
     at_rot_target(integer tnum, rotation targetrot, rotation ourrot)
     at_rot_target(integer tnum, rotation targetrot, rotation ourrot)
        {  
    {  
         llRotTargetRemove( rottarget );
         llRotTargetRemove( rottarget );
         llOwnerSay("there"); //reached the target
         llOwnerSay("there"); //reached the target
        }
    }


     touch_start(integer touched)
     touch_start(integer touched){  
   
    {  
         state default;  
         state default;  
     }
     }

Revision as of 11:02, 22 February 2007

Summary

Function: integer llRotTarget( rotation rot, float error );
0.0 Forced Delay
10.0 Energy

This function is to have the script know when it has reached a rotation.
It registers a rot with a error that triggers at_rot_target and not_at_rot_target events continuously until unregistered.
Returns an integer that is the handle to unregister the target with llRotTargetRemove

• rotation rot
• float error

A similar function exists for positions: llTarget
This function does not rotate the object, to do that use llSetRot or llRotLookAt.

Examples

vector standrot = <0.0, 0.0, 0.0>;
vector fliprot = <45.0, 0.0, 0.0>;

// simple two-state rot target detection and rotation by Hypatia Callisto
// works, to detect a rotation target. An example I wrote
// since there is almost zilch for clean examples for 
// at_rot_target, not_at_rot_target, llRotTarget, llRotTargetRemove

integer rottarget;

default
{

    state_entry(){ 
        rottarget = llRotTarget(llEuler2Rot(fliprot*DEG_TO_RAD), 0.1);
        llSetPrimitiveParams ([PRIM_ROTATION, llEuler2Rot(standrot*DEG_TO_RAD)]); // rotate to standrot
    }

    not_at_rot_target()
        { 
        llRotTargetRemove( rottarget );
        llOwnerSay("not there"); 
        }
        
    touch_start (integer total_number){
        state rotatestate; // change to state for new position
    }
}
             
      
state rotatestate
{ 
    state_entry(){ 
        rottarget = llRotTarget(llEuler2Rot(fliprot*DEG_TO_RAD), 0.1);
        llSetPrimitiveParams ([PRIM_ROTATION, llEuler2Rot(fliprot*DEG_TO_RAD)]); // rotate to new point
    }
    
    at_rot_target(integer tnum, rotation targetrot, rotation ourrot){ 
        llRotTargetRemove( rottarget );
        llOwnerSay("there"); //reached the target
    }

    touch_start(integer touched){ 
        state default; 
    }
    
}

vector standrot = <0.0, 0.0, 0.0>;
vector fliprot = <45.0, 0.0, 0.0>;

// simple two-state rot target detection and rotation by Hypatia Callisto
// works, to detect a rotation target. An example I wrote
// since there is almost zilch for clean examples for 
// at_rot_target, not_at_rot_target, llRotTarget, llRotTargetRemove

integer rottarget;

default
{

    state_entry(){ 
        rottarget = llRotTarget(llEuler2Rot(fliprot*DEG_TO_RAD), 0.1);
        llSetPrimitiveParams ([PRIM_ROTATION, llEuler2Rot(standrot*DEG_TO_RAD)]); // rotate to starting point
    }

    not_at_rot_target()
    { 
        llRotTargetRemove( rottarget );
        llOwnerSay("not there"); //not at target
    }
        
    touch_start (integer total_number)
    {
        state rotatestate; // change to state for new position
    }
}
             
      
state rotatestate 
{ 
    state_entry(){ 
        rottarget = llRotTarget(llEuler2Rot(fliprot*DEG_TO_RAD), 0.1);
        llSetPrimitiveParams ([PRIM_ROTATION, llEuler2Rot(fliprot*DEG_TO_RAD)]); // rotate to new point
    }
    
    at_rot_target(integer tnum, rotation targetrot, rotation ourrot)
    { 
        llRotTargetRemove( rottarget );
        llOwnerSay("there"); //reached the target
    }

    touch_start(integer touched){ 
        state default; 
    }
    
}

Deep Notes

Signature

function integer llRotTarget( rotation rot, float error );