Talk:LlRotTarget

From Second Life Wiki
Revision as of 07:35, 22 February 2007 by Hypatia Callisto (talk | contribs)
Jump to navigation Jump to search

Not exactly sure how to submit an example (I've not edited a wiki before), so I will just put this in the discussion page.

Not much to look at anywhere regarding llRotTarget, llRemoveRotTarget, not_at_rot_target, and at_rot_target. So here's a *working* little example script I cobbled together showing the four in action, whoever wants to add this to the examples page, feel free.

<lsl>


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

}

</lsl>