“LlSetTimerEvent”的版本间的差异
(创建页面,内容为“{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}} {{函数详情 |函数名 = Function: llSetTimerEvent( float sec ); |参数= 参数: •浮点…”) |
|||
| 第47行: | 第47行: | ||
} | } | ||
} | } | ||
| + | </pre> | ||
| + | <pre> | ||
// random period in between (+15.0, +30.0] | // random period in between (+15.0, +30.0] | ||
// which means the resulting float could be 30.0 but not 15.0 | // which means the resulting float could be 30.0 but not 15.0 | ||
| 第54行: | 第56行: | ||
// same results for: | // same results for: | ||
// llSetTimerEvent( 30.0 + llFrand(-15.0) ); | // llSetTimerEvent( 30.0 + llFrand(-15.0) ); | ||
| + | </pre> | ||
| + | <pre> | ||
// The timer event will never fire. | // The timer event will never fire. | ||
default | default | ||
2020年8月12日 (三) 09:04的最新版本
| 首页 | 函数 | 事件 | 类型 | 操作符 | 常数 | Flow Control | Script Library | Categorized Library | Tutorials |
| 函数名 |
|---|
| Function: llSetTimerEvent( float sec ); |
| 参数:
•浮点秒–任何正非零值启用,零(0.0)禁用。 |
| 返回值:使计时器事件最多每秒触发一次。传入0.0将停止进一步的计时器事件。 |
| 注意事项 |
|---|
| 计时器事件之间的时间间隔可能更长,这是由于:
时间膨胀-有关详细信息,请参见llGetRegionTimeScansion。 默认事件延迟-每秒只能触发这么多事件。 事件执行-如果事件的执行时间过长。 计时器在状态更改期间保持不变,但在重置脚本时会被移除。因此,如果您更改为具有timer()事件的状态,并且计时器仍在运行,则它将以新状态激发。 设置一个新的计时器将取代旧的计时器并重置计时器时钟。 如果以小于秒的间隔重复调用此函数,则计时器事件将永远不会触发。 计时器事件不是中断,它不会暂停当前正在运行的事件的执行以执行计时器。当前事件必须在计时器执行之前完成执行。 |
| 示例 |
|---|
示例1
// default of counter is 0 upon script load
integer counter;
float gap = 2.0;
default
{
state_entry()
{
llSetTimerEvent(gap);
}
touch_start(integer total_number)
{
llSay(0, "The timer stops.");
llSetTimerEvent(0.0);
counter = 0;
}
timer()
{
++counter;
llSay(0,
(string)counter+" ticks have passed in " + (string)llGetTime()
+ " script seconds.\nEstimated elapsed time: " + (string)(counter * gap));
}
}
// random period in between (+15.0, +30.0]
// which means the resulting float could be 30.0 but not 15.0
llSetTimerEvent( 30.0 - llFrand(15.0) );
// same results for:
// llSetTimerEvent( 30.0 + llFrand(-15.0) );
// The timer event will never fire.
default
{
state_entry()
{
llSetTimerEvent(5.0);
// Sensor every 2.5 seconds
llSensorRepeat("", NULL_KEY, FALSE, 0.0, 0.0, 2.5);
}
no_sensor()
{
llSetTimerEvent(5.0);
}
timer()
{
llSay(0, "I will never happen.");
llSay(0, "Well, unless llSensorRepeat() magically finds something,"+
"or maybe there's 2.5+ seconds of lag and the timer()"+
"event queues.");
}
}
|
| 相关函数 |
|---|
| llSensorRepeat |
| 相关事件 |
|---|
| timer |