LSL-- Flow Control

Flow Control

 

流控制

 

1. Subcategories

 

1.1 LSL Conditional

 

條件的。

 

1.2 LSL Functions

 

1.3 LSL Operators

 

1.4 LSL User-Defined Functions

 

用戶定義的函數

 

2. Pages

 

2.1 D

 

2.1.1 Default

 

state target { events }

• label target state name

• event events one or more events

target state definition.

 

2.1.1.1 在腳本內不能直接包含用戶定義的函數或變量;只有事件可以定義在state範圍內

 

2.1.1.2 default 狀態定義應其他狀態之前

 

2.1.1.3 狀態不能在用戶定義的全局函數中轉換;如果使用IF,不能使用ELSE

 

2.1.1.4 狀態轉換

 

default

{

    touch_end(integer a)

    {

        state hello;

    }

}

 

state hello

{

    state_entry()

    {

        llOwnerSay("Hello");

        state default;

    }

    state_exit()

    {

        llOwnerSay("Goodbye");

    }

}

 

2.1.1.4.1 所有的listen事件released

 

2.1.1.4.2 所有的事件隊列清除

 

2.1.1.4.3 timer event clock沒有清除

 

2.1.1.5 現在狀態和目標狀態的關係

 

2.1.1.5.1 state_exit()在現在狀態退出時觸發

 

2.1.1.5.2 狀態轉爲trigger,所有的listen未註冊

 

2.1.1.5.3 觸發state_entry()事件,如果在目標狀態

 

2.1.2 Do while

 

do loop while (condition);

loop Executes once, then executes condition.

condition If condition executes true, it then loops back and executes loop again.

 

 

2.2 E

 

2.2.1 Else

 

if ( condition ) branch_true else branch_false

condition If this executes as true then branch_true is executed otherwise branch_false is executed.

branch_true Can be either a single statement, a block statement, or a null statement.

branch_false Can be either a single statement, a block statement, or a null statement.

 

2.3 F

 

2.3.1 For

 

for( initializer; condition; increment ) loop

initializer Executed once just before checking condition.

condition If this executes as true then loop is executed.

increment Executed after loop, then condition is checked again.

loop Can be either a single statement, a block statement, or a null statement.

 

 

2.3.1.1 等效的while

 

A for loop is the same as a while loop as below.

 

initializer;

while(condition)

{

    loop;

    increment;

}

 

2.4 I

 

2.4.1 If

 

2.4.1.1 short circuit

 

// A simple method to say if the method was called.

integer test()

{

    llOwnerSay("Test method called!");

    return TRUE;

}

 

default

{

    touch_start(integer total_number)

    {

        if (FALSE && test())

        { // If short-circuit optimized then the test() should never be called.

          // Will never get here.

        }

    }

}

 

2.4.1.2 複雜的IF/ELSE語句

 

Complex if/else block (only one line of text will be said by this example)

if (a == "Loren") {

    llSay(0, "Lorem ipsum sic amet!");

} else if (a == "Bob") {

    llSay(0, "Babble dabble rabble rouse.");

} else {

    llSay(0, "Gobbledygook?  or English?");

}

 

2.4.1.3 條件的判斷在前,將引起不能編譯

 

在大量的代碼中這將是非常錯誤的。

 

2.5 J

 

2.5.1 Jump

 

2.6 L

 

2.6.1 LSL Addition

 

2.6.1.1 Integer

 

2.6.1.2 Vector

 

2.6.1.3 Rotation

 

2.6.1.4 String

 

2.6.1.5 List

 

列表和列表相加:

List1+List2:將List2加到List1的末尾。List2自動轉換爲List

 

2.7 R

 

2.7.1 Return

 

return value;

• type value value or variable to be returned by the function, the type must be the same as that to be returned by the function.

Used to return execution to the previous scope along with a value.

Functions

Exits the function and continues script execution in the previous scope.

Events

Causes the script to crash. Events cannot return a value. Use the next form of this keyword instead.

 

2.7.1.1 return value

 

返回值;對應函數,退出函數,繼續執行腳本

對應事件,事件不能返回值,故會產生衝突。

Used to prematurely return execution to the previous scope before reaching the end of the function/event. You do not need to use this at the end of an event or function, as it is assumed by the compiler.

Functions

Exits the function and continues script execution in the previous scope.

Events

Exits the event and removes it from the event queue. If there is another event in the queue, that event is triggered.

 

 

2.7.1.2 return

 

無返回值;函數:同上。

事件:退出事件,且將事件從隊列提出。如果隊列中有另一個事件,則該事件觸發。

Used to prematurely return execution to the previous scope before reaching the end of the function/event. You do not need to use this at the end of an event or function, as it is assumed by the compiler.

Functions

Exits the function and continues script execution in the previous scope.

Events

Exits the event and removes it from the event queue. If there is another event in the queue, that event is triggered.

 

2.8 S

 

2.8.1 State

 

2.9 W

 

2.9.1 While

發佈了100 篇原創文章 · 獲贊 2 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章