LlRotTarget: Difference between revisions
No edit summary |
No edit summary |
||
| Line 113: | Line 113: | ||
|also_tests | |also_tests | ||
|also_events= | |also_events= | ||
{{LSL DefineRow | {{LSL DefineRow|[[at_rot_target]]|[[not_at_rot_target]]}|} | ||
{{LSL DefineRow|[[at_target]]|[[not_at_target]]|}} | |||
{{LSL DefineRow | |||
|also_functions= | |also_functions= | ||
{{LSL DefineRow||[[llRotTargetRemove]]|Stop a target rotation}} | {{LSL DefineRow||[[llRotTargetRemove]]|Stop a target rotation}} | ||
Revision as of 14:58, 3 March 2007
{{LSL_Function
|func_id=68|func_sleep=0.0|func_energy=10.0
|func=llRotTarget
|return_type=integer
|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
|func_footnote=A similar function exists for positions: llTarget
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.
It registers a rot with a 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 llRotTargetRemove
|spec
|caveats
|constants
|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;
}
}
|helpers |also_tests |also_events= |-style="vertical-align:top;" | style="color:gray;" |• at_rot_target | not_at_rot_target} | style="color:gray;" | – | } |-style="vertical-align:top;" | style="color:gray;" |• at_target | not_at_target | style="color:gray;" | | |
| also_articles