Difference between revisions of "LlRotTarget"

From Second Life Wiki
Jump to navigation Jump to search
m (Removed duplicate example.)
m (<lsl> tag to <source>)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL Function
|inject-2={{LSL Function/rotation|rot|region=*}}
|func_id=68|func_sleep=0.0|func_energy=10.0
|func_id=68|func_sleep=0.0|func_energy=10.0
|func=llRotTarget
|func=llRotTarget
|return_type=integer
|return_type=integer
|return_subtype=handle
|p1_type=rotation|p1_name=rot|p1_desc=target rotation
|p1_type=rotation|p1_name=rot|p1_desc=target rotation
|p2_type=float|p2_name=error|p2_desc=angle in radians, defines when '''rot''' has been reached
|p2_type=float|p2_name=error|p2_desc=angle in radians, defines when {{LSLP|rot}} has been reached|p2_hover=angle in radians, defines when 'rot' has been reached
|func_footnote=A similar function exists for positions: {{LSLG|llTarget}}<br/>This function does not rotate the object, to do that use {{LSLG|llSetRot}}, {{LSLG|llRotLookAt}} or {{LSLG|llLookAt}}.
|func_footnote=A similar function exists for positions: [[llTarget]]<br/>This function does not rotate the object, to do that use [[llSetRot]], [[llRotLookAt]] or [[llLookAt]].
|func_desc=This function is to have the script know when it has reached a rotation.<br/>It registers a '''rot''' with a '''error''' that triggers {{LSLG|at_rot_target}} and {{LSLG|not_at_rot_target}} events continuously until unregistered.
|func_desc=This function is to have the script know when it has reached a rotation.<br/>It registers a {{LSLP|rot}} with a {{LSLP|error}} that triggers [[at_rot_target]] and [[not_at_rot_target]] events continuously until unregistered.
|return_text=that is the handle to unregister the target with {{LSLG|llRotTargetRemove}}
|return_text=to unregister the target with {{LSLG|llRotTargetRemove}}
|spec
|spec
|caveats
|caveats
|constants
|constants
|examples=
|examples=
<lsl>
<source lang="lsl2">
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 62: Line 64:
      
      
}
}
</lsl>
</source>
|helpers
|helpers
|also_tests
|also_tests
Line 69: Line 71:
{{LSL DefineRow|[[at_target]]|[[not_at_target]]|positional target events}}
{{LSL DefineRow|[[at_target]]|[[not_at_target]]|positional target events}}
|also_functions=
|also_functions=
{{LSL DefineRow||[[llRotTargetRemove]]|Stop a target rotation}}
{{LSL DefineRow||[[llRotTargetRemove]]|Cancel a target rotation}}
{{LSL DefineRow||[[llTarget]]|Setup a target position}}
{{LSL DefineRow||[[llTarget]]|Register a target position}}
{{LSL DefineRow||[[llTargetRemove]]|Stop a target position}}
{{LSL DefineRow||[[llTargetRemove]]|Cancel a target position}}
|also_articles
|also_articles
|notes
|notes
|cat1=Physics
|cat1=Physics
|cat2=Target
|cat2=Target
|cat3
|cat3=At Target
|cat4
|cat4
}}
}}

Latest revision as of 14:40, 22 January 2015

Summary

Function: integer llRotTarget( rotation rot, float error );

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 a handle (an integer) to unregister the target with llRotTargetRemove

• rotation rot target rotation
• float error angle in radians, defines when rot has been reached

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

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 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; 
    }
    
}

See Also

Events

• at_rot_target not_at_rot_target rotational target events
• at_target not_at_target positional target events

Functions

•  llRotTargetRemove Cancel a target rotation
•  llTarget Register a target position
•  llTargetRemove Cancel a target position

Deep Notes

Search JIRA for related Issues

Signature

function integer llRotTarget( rotation rot, float error );