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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值