OpenSim: LSL2CS
From OpenSimulator
(Difference between revisions)
Steevithak (Talk | contribs) m (cleaned up code spacing) |
|||
Line 3: | Line 3: | ||
{ | { | ||
− | + | integer i; | |
− | + | for( i=0; i<13;i++ ) | |
− | + | { | |
− | + | llSay(0,(string)i); | |
− | + | } | |
} | } | ||
Line 17: | Line 17: | ||
state_entry() | state_entry() | ||
{ | { | ||
− | + | llSay(0,"started"); | |
− | + | integer i; | |
− | + | i=0; | |
− | + | while( i<13 ) | |
− | + | { | |
− | + | llSay(0,(string)i); | |
− | + | i++; | |
− | + | } | |
− | + | llSay(0,"finished"); | |
} | } | ||
} | } | ||
Line 35: | Line 35: | ||
{ | { | ||
− | + | int i; | |
− | + | i=0; | |
− | + | SetScope( delegate() | |
− | + | { return i<13; }, | |
− | + | delegate() | |
− | + | { | |
− | + | llSay(0,(string)i); | |
− | + | i++; | |
− | + | }, delegate() | |
− | + | { | |
− | + | llSay(0,"finished"); | |
− | + | } | |
− | + | ); | |
} | } | ||
Revision as of 07:27, 30 September 2020
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.