LlSensorRepeat
Looking for the current API? Open the llSensorRepeat reference →
Wiki description
Performs a scan for
name and id with type within range meters and arc radians of forward vector and repeats every rate seconds. The first scan is not performed until rate seconds have passed.Function notes
If
If
Depending upon which AGENT* flag is used determines the format requirements for
name, id, and/or type are empty or 0, they are ignored.If
id is an invalid key or NULL_KEY it is treated as empty.Depending upon which AGENT* flag is used determines the format requirements for
nameSee: llSensor for an excellent explanation of
arc.Caveats
- The repeat of the sensor event is adversely affected by time dilation (lag).
- Sensors placed in the root prim of attachments will use the direction the avatar is facing as their forward vector. In mouselook, this means that it will be wherever the avatar is looking, while out of mouselook, this means whichever way the avatar is pointing. This does not include where the avatar's head is pointing, or what animation the avatar is doing, just the direction the avatar would move in if you walked forward. This is the case, regardless of where the object is attached.
- Sensors placed in prims other than the root prim of an attachment will have their forward direction offset relative to the root prim's forward direction, e.g. a sensor in a prim whose +X direction is the reverse of the root +X will look backward.
- Only the most recent sensor event is queued. Previous sensor events are replaced.
- A repeating sensor does not persist across a state change.
- llSensorRepeat can occasionally detect outside of it's specified range every few cycles when used near sim borders. llSensor in a timer does not.
- Only one or zero llSensorRepeats can be active per script. If llSensorRepeat is called a second time without calling llSensorRemove, the first llSensorRepeat is deactivated and the second one replaces it
Examples
// 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;
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_BY_LEGACY_NAME, 10.0, PI, 30.0);
}
sensor(integer num_detected)
{
string thisAgent;
integer agentNum;
for (agentNum=0; agentNum<num_detected; agentNum++)
{
thisAgent = llDetectedName(agentNum);
if (llDetectedKey(agentNum) == 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;
}
}
}
}// Written by Evans Love.
// (Limited to most recent 200 names by Void Singer to prevent eventual Stack/Heap Collision + clean up)
// Continuously scans for visitors within 10 meters and reports new visitors to object owner.
//-------------------------------------------------------------------------------------
integer RESPONSE_CHANNEL = -100;
float SCAN_RANGE = 10.0;
float SCAN_INTERVAL = 20.0;
list VISITOR_LIST;
default
{
state_entry()
{
llSensorRepeat("", NULL_KEY, AGENT_BY_LEGACY_NAME, SCAN_RANGE, PI, SCAN_INTERVAL);
}
sensor(integer number_detected)
{
integer agent_number;
// iterate through all detected agents
for (; agent_number < number_detected; agent_number++)
{
string this_agent_name = llDetectedName(agent_number);
key this_agent_key = llDetectedKey(agent_number);
// if the agent is not found on the list
if (llListFindList(VISITOR_LIST, [this_agent_name]) == -1)
{
// add her/him and make the list hold the last 200 visitors
VISITOR_LIST = [this_agent_name] + llList2List(VISITOR_LIST, 0, 198);
llDialog(this_agent_key, "Welcome!", ["Ok"], RESPONSE_CHANNEL);
llOwnerSay(this_agent_name);
}
// else agent is already on the list
}
}
}Notes
See also: functions
See also: events
Shared wiki helpers
The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.
Original shared helper source (conditional wiki logic is not evaluated)
<noinclude>{{Multi-lang|category=LSL}}</noinclude>{{LSL Injection Test}}{{#if:
{{#vardefine:p_{{{1|none}}}_desc|{{#if:{{{pd|}}}|{{{pd|}}} }}{{#if:{{{group|1}}}|{{LSLGC|Group|group}}, }}{{LSLGC|Avatar|avatar}} or {{#if:{{{object|}}}|[[object]]|[[prim]]}} {{HoverLink|UUID|Universally Unique Identifier}} {{#if:{{{sim|}}}|that is in the same [[region]] {{#switch:{{{sim|}}}|*=|#default =  {{{sim|}}}}}
}}}}
{{#vardefine:p_{{{1|none}}}_hover|{{#if:{{{ph|}}}|{{{ph|}}} |{{#if:{{{pd|}}}|{{{pd|}}} }}}}{{#if:{{{group|1}}}|group, }}avatar or {{#if:{{{object|}}}|object|prim}} UUID {{#if:{{{sim|}}}|that is in the same region {{#switch:{{{sim|}}}|*=|#default =  {{{sim|}}}}}
}}}}
<includeonly>
{{#ifeq:{{#var:article-type}}|event||{{#if:{{#pos:{{#var:moded}}|r}}{{#pos:{{#var:moded}}|u}}||{{#vardefine:hidden-text|{{#var:hidden-text}}
{{LSLC|Avatar/As A Parameter}}
}}}}}}
</includeonly>
}}<noinclude>
{| {{Prettytable}}
|-{{Hl2}}
!var
!value
|-
|desc
|{{#var:p_{{{1|none}}}_desc}}
|-
|hover
|{{#var:p_{{{1|none}}}_hover}}
|}
</noinclude>Template:LSL Constants/Sensing
Original shared helper source (conditional wiki logic is not evaluated)
{{#if:
{{#vardefine:caveats|{{#var:caveats}}
*When searching for an avatar but not by name, it doesn't matter which AGENT flag is used.}}
{{#vardefine:constants_nb|{{#var:constants_nb}}
{{{!}}
{{LSL Constants Sensor|{{{1|}}}|no_wrapper=*|tstyle=margin-top:0;}}
<div style="display:inline-block;">
{{{!}} {{Prettytable|style=margin-top:0;}}
{{!}}- {{Hl2}}
!Float Constants
!Arc
{{!}}-
{{!}}{{#vardefine:PI_BY_TWO|{{LSL Const|PI_BY_TWO|float|1.570796326}}}}{{#var:PI_BY_TWO}}
{{!}}A hemisphere scan
{{!}}-
{{!}}{{#vardefine:PI|{{LSL Const|PI|float|3.141592653}}}}{{#var:PI}}
{{!}}A full sphere scan
{{!}}}
</div>
{{!}}}
}}
}}<noinclude>{{#var:constants_nb}}</noinclude>Original shared helper source (conditional wiki logic is not evaluated)
{{#if:
<!--
{{#vardefine:caveats|{{#var:caveats}}
*[[no_sensor]] will not be triggered unless the script has a [[sensor]] event ~ [[#SVC-2409|SVC-2409]]
**An empty [[sensor]] event is enough to satisfy this condition and cause [[no_sensor]] to be triggered.
}}
-->
}}{{Issues|SVC-2409|[[llSensorRepeat]] not triggering [[no_sensor]] unless a [[sensor]] event handler is present|type=bug|resolution=fixed}}Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|SVC-4301|[[llSensorRepeat]] randomly returns unexpected results if <code>{{LSLPT|arc}}>[[PI]]</code>|type=bug|resolution=more}}Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|SVC-6662|type=bug|status=ack|resolution=unres|[[llSensorRepeat]] sometimes detects Avatars in adjacent sims, even though they are beyond the specified sensor range}}Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|BUG-2366|[[llSensor]] removes the sensor repeat if called AFTER [[llSensorRepeat]]|type=bug|status=accepted|resolution=unres}}Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.