From Second Life Wiki
SensorRepeat
llSensorRepeat
前方ベクトルのarcラジアンとrangeメートルで、nameとid、typeで一回スキャンを実行し、それをrate秒毎に繰り返します。
| • string
| name
|
|
|
|
| • key
| id
|
|
|
|
| • integer
| type
| –
| 型フラグ
|
|
| • float
| range
|
|
|
|
| • float
| arc
|
|
|
|
| • float
| rate
|
|
|
|
name、id、そして(または)typeが空あるいは0の場合、これらは無効化されます。idが無効なキーあるいはNULL_KEYの場合、空として扱われます。
arcの素晴らしい説明はllSensorを見ましょう。.
| 型フラグ
| 解説
|
| AGENT
| 0x1
|
|
| ACTIVE
| 0x2
| 移動しているオブジェクトを発見するセンサに用いられます。
|
|
| 型フラグ
| 解説
|
| PASSIVE
| 0x4
| 移動していないオブジェクトを発見するセンサに用いられます。
|
| SCRIPTED
| 0x8
| スクリプトが付与されたオブジェクトを発見するセンサに用いられます。
|
|
警告
- センサーイベントの繰り返しは、時間遅延(ラグ)に逆らって成立します。
例
// Written by Steamy Latte.
// Scans every 30 seconds for visitors within 10 meters.
// Reports new visitors to object owner when she is in range.
string AllAgents;
string OwnerName;
default
{
state_entry()
{
// arc=PI is a sphere, you could look more narrowly in the direction object is facing with PI/2, PI/4 etc.
// don't repeat this too often to avoid lag.
llSensorRepeat("", "", AGENT, 10.0, PI, 30.0);
}
sensor(integer num_detected)
{
string thisAgent = "";
integer agentNum;
for (agentNum=0; agentNum<num_detected; agentNum++)
{
key thisKey = llDetectedKey(agentNum);
string thisAgent = llDetectedName(agentNum);
if (thisKey == llGetOwner())
{
if (AllAgents != "")
{
llOwnerSay("We've had the following visitors:" + AllAgents);
AllAgents = "";
}
}
else if (llSubStringIndex(AllAgents+"\n", "\n"+thisAgent+"\n") < 0)
{
AllAgents = AllAgents + "\n" + thisAgent;
}
}
}
}