Difference between revisions of "Template:LSL Constants Sensor"
Jump to navigation
Jump to search
Mako Nozaki (talk | contribs) m (added also_articles) |
Mako Nozaki (talk | contribs) (moved samples into template) |
||
Line 46: | Line 46: | ||
{{#if:{{{no_wrapper|}}}||{{!}}} }} | {{#if:{{{no_wrapper|}}}||{{!}}} }} | ||
{{#vardefine:also_articles|{{#var:also_articles}}*http://lslwiki.net/lslwiki/wakka.php?wakka=ObjectType}} | {{#vardefine:also_articles|{{#var:also_articles}}*[http://lslwiki.net/lslwiki/wakka.php?wakka=ObjectType Object Type]}} | ||
{{#if:{{{examples|}}}| | |||
{{#vardefine:examples|{{#var:examples}} | |||
Using llDetectedType() in collision event: | |||
<lsl> | |||
integer type; | |||
default | |||
{ | |||
state_entry() | |||
{ | |||
llVolumeDetect(TRUE); | |||
} | |||
collision_start(integer detected) | |||
{ | |||
type = llDetectedType(0); | |||
if(type == AGENT)// = 1 | |||
{ | |||
llSay(0, "This is impossible. Since there is no avatar who doesn't require the physical calculation."); | |||
} | |||
else if(type == ACTIVE)// = 2 | |||
{ | |||
llSay(0, "I have been struck by a physical object not containing any active script."); | |||
} | |||
else if(type == PASSIVE)// = 4 | |||
{ | |||
llSay(0, "This is impossible. Non-physical objects cannot trigger this event."); | |||
} | |||
else if(type == SCRIPTED)// = 8 | |||
{ | |||
llSay(0, "This is impossible. Since there is no object which isn't physical nor non-physical."); | |||
} | |||
else if(type == 3)// AGENT & ACTIVE | |||
{ | |||
llSay(0, "I have been struck by an avatar."); | |||
} | |||
else if(type == 10)// SCRIPTED & ACTIVE | |||
{ | |||
llSay(0, "I have been struck by a phisical object containing any active script."); | |||
} | |||
else if(type == 12)// SCRIPTED & PASSIVE | |||
{ | |||
llSay(0, "This is impossible. Non-physical objects cannot trigger this event."); | |||
} | |||
} | |||
} | |||
</lsl> | |||
Using llDetectedType() in sensor event: | |||
<lsl> | |||
default | |||
{ | |||
touch_start(integer numberDetected) | |||
{ | |||
llSensor("", "", (ACTIVE|PASSIVE|AGENT), 20.0, PI); // activates the sensor. | |||
} | |||
sensor (integer numberDetected) | |||
{ | |||
integer i = 0; | |||
while(i < numberDetected) | |||
{ | |||
integer type = llDetectedType(i); | |||
string message; | |||
message += (string)i + ", " + llDetectedName(i) + ", "; | |||
list typeList; | |||
if(AGENT & type) | |||
{ | |||
typeList += "AGENT"; | |||
} | |||
if(ACTIVE & type) | |||
{ | |||
typeList += "ACTIVE"; | |||
} | |||
if(PASSIVE & type) | |||
{ | |||
typeList += "PASSIVE"; | |||
} | |||
if(SCRIPTED & type) | |||
{ | |||
typeList += "SCRIPTED"; | |||
} | |||
message += llDumpList2String(typeList, "|"); | |||
llWhisper(0, message); | |||
i++; | |||
} | |||
} | |||
no_sensor() | |||
{ | |||
// This is impossible if range = 20.0 and you are standing within 10m! | |||
llWhisper(0, "Nothing is near me at present."); | |||
} | |||
} | |||
</lsl> | |||
Using as the filter for llSensor*() functions: | |||
<lsl> | |||
integer done; | |||
tellit(integer detected) | |||
{ | |||
integer i = 0; | |||
while(i < detected) | |||
{ | |||
integer type = llDetectedType(i); | |||
string message; | |||
llWhisper(0, (string)i + ", " + llDetectedName(i)); | |||
i++; | |||
} | |||
} | |||
default | |||
{ | |||
touch_start(integer detected) | |||
{ | |||
llWhisper(0, "AGENT"); | |||
llSensor("", "", AGENT, 20.0, PI); | |||
} | |||
sensor(integer detected) | |||
{ | |||
if(done == 0) | |||
{ | |||
tellit(detected); | |||
llWhisper(0, "ACTIVE"); | |||
llSensor("", "", ACTIVE, 20.0, PI); | |||
++done; | |||
} | |||
else if(done == 1) | |||
{ | |||
tellit(detected); | |||
llWhisper(0, "AGENT|ACTIVE"); | |||
llSensor("", "", AGENT|ACTIVE, 20.0, PI); | |||
++done; | |||
} | |||
else if(done == 2) | |||
{ | |||
tellit(detected); | |||
llWhisper(0, "PASSIVE"); | |||
llSensor("", "", PASSIVE, 20.0, PI); | |||
++done; | |||
} | |||
else if(done == 3) | |||
{ | |||
tellit(detected); | |||
llWhisper(0, "AGENT|PASSIVE"); | |||
llSensor("", "", AGENT|PASSIVE, 20.0, PI); | |||
++done; | |||
} | |||
else if(done == 4) | |||
{ | |||
tellit(detected); | |||
llWhisper(0, "ACTIVE|PASSIVE"); | |||
llSensor("", "", ACTIVE|PASSIVE, 20.0, PI); | |||
++done; | |||
} | |||
else if(done == 5) | |||
{ | |||
tellit(detected); | |||
llWhisper(0, "AGENT|ACTIVE|PASSIVE"); | |||
llSensor("", "", AGENT|ACTIVE|PASSIVE, 20.0, PI); | |||
++done; | |||
} | |||
else if(done == 6) | |||
{ | |||
tellit(detected); | |||
llWhisper(0, "SCRIPTED"); | |||
llSensor("", "", SCRIPTED, 20.0, PI); | |||
++done; | |||
} | |||
else if(done == 7) | |||
{ | |||
tellit(detected); | |||
llWhisper(0, "AGENT|SCRIPTED"); | |||
llSensor("", "", AGENT|SCRIPTED, 20.0, PI); | |||
++done; | |||
} | |||
else if(done == 8) | |||
{ | |||
tellit(detected); | |||
llWhisper(0, "ACTIVE|SCRIPTED"); | |||
llSensor("", "", ACTIVE|SCRIPTED, 20.0, PI); | |||
++done; | |||
} | |||
else if(done == 9) | |||
{ | |||
tellit(detected); | |||
llWhisper(0, "AGENT|ACTIVE|SCRIPTED"); | |||
llSensor("", "", AGENT|ACTIVE|SCRIPTED, 20.0, PI); | |||
++done; | |||
} | |||
else if(done == 10) | |||
{ | |||
tellit(detected); | |||
llWhisper(0, "PASSIVE|SCRIPTED"); | |||
llSensor("", "", PASSIVE|SCRIPTED, 20.0, PI); | |||
++done; | |||
} | |||
else if(done == 11) | |||
{ | |||
tellit(detected); | |||
llSay(0, "Phew!"); | |||
} | |||
} | |||
no_sensor() | |||
{ | |||
llWhisper(0, "None."); | |||
if(done == 11) | |||
{ | |||
llSay(0, "Phew!"); | |||
} | |||
else | |||
{ | |||
++done; | |||
} | |||
} | |||
} | |||
</lsl> | |||
see [http://lslwiki.net/lslwiki/wakka.php?wakka=ObjectType Object Type] for detail | |||
}}}} | |||
<noinclude>{{#var:examples}}</noinclude> |
Revision as of 02:17, 22 May 2010
|