Difference between revisions of "User:ANSI Soderstrom/Threading with LSL"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with '== Leave a comment == * [[User_talk:{{PAGENAME}}|My User Talk about this Page]] == All About : Threating with LSL == Bla bla <lsl> default { state_entry() { llR...')
 
Line 2: Line 2:
* [[User_talk:{{PAGENAME}}|My User Talk about this Page]]
* [[User_talk:{{PAGENAME}}|My User Talk about this Page]]


== All About : Threating with LSL ==
== All About : Threating with LSL (Creating Low-Lag-Items) ==
Bla bla
 
Some functions in SL creating a lot of lag on the server-side. But the greatest lag is not coming from llSetRot() or something like that, but from loops !!!
Do->while and for->to->next loops are the greatest lagproducers at the beginners level in SL. Furthermore its impossible to trigger a Event while a loop is running.
 
Some people say, timers are the godlike-laggers, but now we learn how to use timers for the opposite :)
 
We try to rotate the Prim around a angle of 360 degrees and producing no lag, because we wait at every loop for free server-power and can handle events while the loop is running.


<lsl>
<lsl>
integer LOOP_COUNT;
float  THREATING_SPEED = 0.001; // 0.25 is nearby a NULL-Lag item !
default
default
{
{
     state_entry()
     state_entry()
     {
     {
         llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
         // use the timer event instead of a loop and make sure we can handle events while the loop is running...
        LOOP_COUNT = 360;
        llSetTimerEvent(THREATING_SPEED);
     }
     }


     timer() {
     timer() {
        // save serverPower
        llSetTimerEvent(0);


        // Do a loop (if possible)
        if(LOOP_COUNT) {
            // Rotate the Prim around his axis
            llSetRot(llGetRot()/llEuler2Rot(<0,0,LOOP_COUNT>*DEG_TO_RAD));
            // increment the loop
            --LOOP_COUNT;
            // look for events and do again the loop
            llSetTimerEvent(THREATING_SPEED);
        }
     }
     }
}
}
</lsl>
</lsl>

Revision as of 02:19, 4 October 2010

Leave a comment

All About : Threating with LSL (Creating Low-Lag-Items)

Some functions in SL creating a lot of lag on the server-side. But the greatest lag is not coming from llSetRot() or something like that, but from loops !!! Do->while and for->to->next loops are the greatest lagproducers at the beginners level in SL. Furthermore its impossible to trigger a Event while a loop is running.

Some people say, timers are the godlike-laggers, but now we learn how to use timers for the opposite :)

We try to rotate the Prim around a angle of 360 degrees and producing no lag, because we wait at every loop for free server-power and can handle events while the loop is running.

<lsl> integer LOOP_COUNT; float THREATING_SPEED = 0.001; // 0.25 is nearby a NULL-Lag item !

default {

   state_entry()
   {
       // use the timer event instead of a loop and make sure we can handle events while the loop is running...
       LOOP_COUNT = 360;
       llSetTimerEvent(THREATING_SPEED);
   }
   timer() {
       // save serverPower
       llSetTimerEvent(0);
       // Do a loop (if possible)
       if(LOOP_COUNT) {
           // Rotate the Prim around his axis
           llSetRot(llGetRot()/llEuler2Rot(<0,0,LOOP_COUNT>*DEG_TO_RAD));
           // increment the loop
           --LOOP_COUNT;
           // look for events and do again the loop
           llSetTimerEvent(THREATING_SPEED);
       }
   }

} </lsl>