OpenSim: LSL2CS: Difference between revisions

From OpenSimulator
Jump to navigationJump to search
imported>Lbsa71
No edit summary
 
imported>Lbsa71
No edit summary
Line 1: Line 1:
default {
default {
    state_entry()
    state_entry()
    {
    {


integer i;
integer i;
for( i=0; i<13;i++ )
for( i=0; i<13;i++ )
{
{
  llSay(0,(string)i);
  llSay(0,(string)i);
}
}
 
    }
    }
}
}


--- can be transformed to
--- can be transformed to


default {
default {
    state_entry()
    state_entry()
    {
    {
  llSay(0,"started");
  llSay(0,"started");
 
integer i;
integer i;
i=0;
i=0;
while( i<13 )
while( i<13 )
{
{
  llSay(0,(string)i);
  llSay(0,(string)i);
  i++;
  i++;
}
}
  llSay(0,"finished");
  llSay(0,"finished");
 
    }
    }
}
}


--- can be transformed to
--- can be transformed to


    void state_entry()
    void state_entry()
    {
    {
 
int i;
int i;
i=0;
i=0;


SetScope( delegate()  
SetScope( delegate()  
{ return i<13; },  
{ return i<13; },  
delegate()  
  delegate()  
{
{
  llSay(0,(string)i);
  llSay(0,(string)i);
  i++;
  i++;
}, delegate()
}, delegate()
{
{
  llSay(0,"finished");
  llSay(0,"finished");
}
}
);
);
    }
    }


---
---


In the above code, the engine will test the condition and call the 'current scope' until the condition is false, then it will set current scope to null and run the third delegate.
In the above code, the engine will test the condition and call the 'current scope' until the condition is false, then it will set current scope to null and run the third delegate.

Revision as of 13:15, 21 August 2007

default {
    state_entry()
    {
integer i;
for( i=0; i<13;i++ )
{
  llSay(0,(string)i);
}

    }
}

--- can be transformed to

default {
    state_entry()
    {
  llSay(0,"started");

integer i;
i=0;
while( i<13 )
{
  llSay(0,(string)i);
  i++;
}
  llSay(0,"finished");
    }
}

--- can be transformed to

    void state_entry()
    {

int i;
i=0;
SetScope( delegate() 
{ return i<13; }, 
 delegate() 
{
  llSay(0,(string)i);
  i++;
}, delegate()
{
  llSay(0,"finished");
}
);
    }

---

In the above code, the engine will test the condition and call the 'current scope' until the condition is false, then it will set current scope to null and run the third delegate.