OpenSim: LSL2CS

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
 
m (Indentation and syntax highlighting)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
default {
+
<source lang="lsl">
 +
default
 +
{
 
     state_entry()
 
     state_entry()
 
     {
 
     {
 +
        integer i;
  
integer i;
+
        for(i = 0; i < 13; i++)
for( i=0; i<13;i++ )
+
        {
{
+
            llSay(PUBLIC_CHANNEL, (string)i);
  llSay(0,(string)i);
+
        }
}
+
 
+
 
     }
 
     }
 
}
 
}
 +
</source>
  
 
--- can be transformed to
 
--- can be transformed to
  
default {
+
<source lang="lsl">
 +
default
 +
{
 
     state_entry()
 
     state_entry()
 
     {
 
     {
  llSay(0,"started");
+
        llSay(PUBLIC_CHANNEL, "started");
  
integer i;
+
        integer i;
i=0;
+
        i = 0;
while( i<13 )
+
 
{
+
        while(i < 13)
  llSay(0,(string)i);
+
        {
  i++;
+
            llSay(PUBLIC_CHANNEL, (string)i);
}
+
            i++;
  llSay(0,"finished");
+
        }
  
 +
        llSay(PUBLIC_CHANNEL, "finished");
 
     }
 
     }
 
}
 
}
 +
</source>
  
 
--- can be transformed to
 
--- can be transformed to
  
    void state_entry()
+
<source lang="CSharp">
    {
+
void state_entry()
 +
{
 +
    int i;
 +
    i = 0;
  
int i;
+
    SetScope(
i=0;
+
        delegate()  
 
+
        {
SetScope( delegate()  
+
            return i < 13;
{ return i<13; },  
+
        }, delegate()
delegate()  
+
        {
{
+
            llSay(PUBLIC_CHANNEL, (string)i);
  llSay(0,(string)i);
+
            i++;
  i++;
+
        }, delegate()
}, delegate()
+
        {
{
+
            llSay(PUBLIC_CHANNEL, "finished");
  llSay(0,"finished");
+
        }
 +
    );
 
}
 
}
);
+
</source>
    }
+
  
 
---
 
---
  
 
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.

Latest revision as of 09:54, 30 September 2020

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

--- can be transformed to

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

--- can be transformed to

void state_entry()
{
    int i;
    i = 0;
 
    SetScope(
        delegate() 
        {
            return i < 13;
        }, delegate()
        {
            llSay(PUBLIC_CHANNEL, (string)i);
            i++;
        }, delegate()
        {
            llSay(PUBLIC_CHANNEL, "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.

Personal tools
General
About This Wiki