User talk:Kimm Paulino/Scripts1

From Second Life Wiki
Jump to navigation Jump to search

Hello Kimm,

Your non-physical move and rotate script is jerky because you're using llSetPos() which has a built-in delay of 0.2 secs.

Replacing the llSetPos() with this line makes it much smoother:-

       llSetLinkPrimitiveParamsFast ( LINK_THIS, [PRIM_POSITION, gCurrentPosition] );

Omei Qunhua 17:45, 28 December 2012 (PST)

Looking again, there's a lot of do-nothing code that can come out like all the stuff involving gState

           if (gState == DOWN)
           {
               gState = GO_UP;
               gState = UP;     // ? eh? you've just set it to GO_UP
           }
           else if (gState == UP)
           {
               gState = GO_DOWN;
               gState = DOWN;    // ?eh?
           }

anyway, gState never gets used.

You can initialise global variables like gDirection where you declare them rather than setting values in state_entry.

So you script can reduce to: <lsl> // Period for the up/down movement is MOVE_COUNT * MOVE_TIME integer MOVE_COUNT = 40; float MOVE_TIME = 0.1;

// Rotation value to use vector gRotationAxis = <0.0, 0.0, 1.0>; float gPiDivisor = 2.0;

// The vector to add to the start position for MOVE_COUNT times vector gOffset = <0.0, 0.0, 0.05>; vector gCurrentPosition; integer gCount; integer gDirection = 1;

default {

   state_entry()
   {
       gCurrentPosition = llGetPos();
       // Start the rotation
       llTargetOmega (gRotationAxis, PI/gPiDivisor, 1.0);
       llSetTimerEvent (MOVE_TIME);
   }

   on_rez(integer n)
   {
       llResetScript();
   }

   timer ()
   {
       gCount++;
       if (gCount > MOVE_COUNT)
       {
           gCount = 0;
           gDirection = -gDirection;
       }
       gCurrentPosition += (gOffset * gDirection); 
       llSetLinkPrimitiveParamsFast ( LINK_THIS, [PRIM_POSITION, gCurrentPosition] );
   }

} </lsl> Omei Qunhua 01:48, 29 December 2012 (PST)