Difference between revisions of "User:Haravikk Mistral/LlCastRay"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with '{{LSL_Function |func_id|mode=request |func_sleep=0.0 |func_energy=10.0 |func=llCastRay |sort=CastRay |p1_type=vector|p1_name=normal |p2_type=float|p2_name=range |p3_type=integer|...')
 
m
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{LSL_Function
{{Issues/SVC-6442}}{{LSL_Function
|func_id|mode=request
|func_id|mode=request
|func_sleep=0.0
|func_sleep=0.0
Line 5: Line 5:
|func=llCastRay
|func=llCastRay
|sort=CastRay
|sort=CastRay
|p1_type=vector|p1_name=normal
|p1_type=vector|p1_name=origin
|p2_type=float|p2_name=range
|p2_type=vector|p2_name=normal
|p3_type=integer|p3_name=type
|p3_type=float|p3_name=range
|p4_type=list|p4_name=detect
|p4_type=integer|p4_name=type
|func_desc=Casts a ray from the scripted prim's centre along the direction described by <code>normal</code> until either <code>range</code> is reached, the ray hits a region boundary, or the results limit is reached.
|p5_type=list|p5_name=detect
|func_desc=Casts a ray from <code>origin</code> along the direction described by <code>normal</code> until either <code>range</code> is reached, the ray hits a region boundary, or the results limit is reached.
|return_text=
|return_text=
|constants={{User:Haravikk_Mistral/Sensor/Types}}
|constants={{User:Haravikk_Mistral/Sensor/Types}}
Line 17: Line 18:
|caveats=* A <code>range</code> of 0.0 or less will be ignored. Under LSO-LSL the maximum value of float can be used for what is effectively an infinity value, while under Mono true infinity can be provided.
|caveats=* A <code>range</code> of 0.0 or less will be ignored. Under LSO-LSL the maximum value of float can be used for what is effectively an infinity value, while under Mono true infinity can be provided.
* This function will return a maximum of 16 results (the limit of the [[sensor]]() event). The results are ordered such that the nearest result is first, followed by the second, and so-on.
* This function will return a maximum of 16 results (the limit of the [[sensor]]() event). The results are ordered such that the nearest result is first, followed by the second, and so-on.
* Only a single ray-cast can be performed by a script at a time; calling this function again before the <code>sensor()</code> event is triggered will interrupt the in-progress ray-cast and begin a new one.
* The [[sensor]]() and [[no_sensor]]() events may not trigger (ray-cast silently fails) if your script is triggering ray-casts too frequently. The simulator will make a best effort to complete requests, though these may be delayed depending upon script or physics-lag for the region.
|examples=<lsl>default {
|examples=<lsl>default {
     state_entry() {
     state_entry() {
Line 22: Line 25:
     }
     }
     timer() {
     timer() {
         llCastRay(llRot2Fwd(llGetRot()), 20.0, AGENT, [DETECT_KEY, DETECT_NAME]);
         llCastRay(llRot2Fwd(llGetRot()), 20.0, AGENT, [DETECT_NAME]);
     }
     }
     sensor(integer x) {
     sensor(integer x) {

Latest revision as of 07:17, 5 November 2010

Emblem-important-yellow.png LSL Feature Request
The described function does not exist. This article is a feature request.

Summary

Function: llCastRay( vector origin, vector normal, float range, integer type, list detect );
0.0 Forced Delay
10.0 Energy

Casts a ray from origin along the direction described by normal until either range is reached, the ray hits a region boundary, or the results limit is reached.

• vector origin
• vector normal
• float range
• integer type
• list detect

Specification

  • Results are filtered by type (see below), and the data to capture is described by detect (see below, default is [DETECT_KEY, DETECT_TYPE]).
  • This function will trigger a sensor() event with any results found, or a no_sensor() event if no results were detected. The usable llDetected*() functions within the sensor event are determined by detect.

Constant Description
AGENT Avatars, optionally identified by their display name.
AGENT_BY_LEGACY_NAME Avatars, optionally identified by their legacy name.
AGENT_BY_USERNAME Avatars, optionally identified by their username.
ACTIVE Physical objects that are moving or objects containing an active script.
PASSIVE Non-scripted or script is inactive and non-physical or, if physical, not moving.
SCRIPTED Objects that has any script, which is doing anything in simulator just now.
LAND The simulator's ground segments (only supported by llCastRay()).


Constant Description
DETECT_ALL Convenience entry to return all available data. Essentially this is the same as providing a list with all other DETECT_* constants valid for the current function, excluding those asking specifically for root-prims, avatar username, or avatar legacy name.
DETECT_GROUP Populates llDetectedGroup() with the key of the group that the detected object, avatar, or land belongs to.
DETECT_KEY Populates llDetectedKey() with the key of the primitive or avatar that was detected. If land is detected this value will be NULL_KEY.
DETECT_ROOT_KEY Populates llDetectedKey() with the key of the object root or avatar that was detected. If land is detected this value will be NULL_KEY.
DETECT_LINK_NUMBER Populates llDetectedLinkNumber() with the link-number of the primitive that was detected. If an avatar or land were struck then this will be zero.
DETECT_NAME Populates llDetectedName() with the name of the primitive or the display name of the avatar that was detected. If land is detected this value will be an empty string.
DETECT_ROOT_NAME Populates llDetectedName() with the name of the object root or display name of the avatar that was detected. If land is detected this value will be an empty string.
DETECT_LEGACY_NAME Populates llDetectedName() with the name of the primitive or the legacy name of the avatar that was detected. If land is detected this value will be an empty string.
DETECT_ROOT_LEGACY_NAME Populates llDetectedName() with the name of the object root or legacy name of the avatar that was detected. If land is detected this value will be an empty string.
DETECT_USERNAME Populates llDetectedName() with the name of the primitive or the legacy name of the avatar that was detected. If land is detected this value will be an empty string.
DETECT_ROOT_USERNAME Populates llDetectedName() with the name of the object root or username of the avatar that was detected. If land is detected this value will be an empty string.
DETECT_OWNER Populates llDetectedOwner() with the UUID of the avatar that owns the detected object or land. If an avatar is detected then their key is returned here.
DETECT_POSITION Populates llDetectedPos() with the position of the primitive that was detected.
DETECT_ROOT_POSITION Populates llDetectedPos() with the position of the object root that was detected.
DETECT_ROTATION Populates llDetectedRot() with the rotation of the primitive that was detected.
DETECT_ROOT_ROTATION Populates llDetectedRot() with the rotation of the object root that was detected.
DETECT_TOUCH_BINORMAL Populates llDetectedTouchBinormal() with the tangental normal vector of the point at which the object was detected.
DETECT_TOUCH_FACE Populates llDetectedTouchFace() with the primitive face that was detected. If an avatar or land were detected then this will be TOUCH_INVALID_FACE.
DETECT_TOUCH_NORMAL Populates llDetectedTouchNormal() with the normal vector of the point at which the object was detected.
DETECT_TOUCH_ST Populates llDetectedTouchST() with the face coordinates of the point at which the object was detected. If an avatar or land are detected then this will be TOUCH_INVALID_TEXCOORD.
DETECT_TOUCH_UV Populates llDetectedTouchUV() with the texture coordinates of the point at which the object was detected. If an avatar or land are struck then this will be TOUCH_INVALID_TEXCOORD.
DETECT_TYPE Populates llDetectedType() with the type of object that was detected.
DETECT_VELOCITY Populates llDetectedVel() with the velocity of the object that was detected.

Caveats

  • A range of 0.0 or less will be ignored. Under LSO-LSL the maximum value of float can be used for what is effectively an infinity value, while under Mono true infinity can be provided.
  • This function will return a maximum of 16 results (the limit of the sensor() event). The results are ordered such that the nearest result is first, followed by the second, and so-on.
  • Only a single ray-cast can be performed by a script at a time; calling this function again before the sensor() event is triggered will interrupt the in-progress ray-cast and begin a new one.
  • The sensor() and no_sensor() events may not trigger (ray-cast silently fails) if your script is triggering ray-casts too frequently. The simulator will make a best effort to complete requests, though these may be delayed depending upon script or physics-lag for the region.

Examples

<lsl>default {

   state_entry() {
       llSetTimerEvent(30.0);
   }
   timer() {
       llCastRay(llRot2Fwd(llGetRot()), 20.0, AGENT, [DETECT_NAME]);
   }
   sensor(integer x) {
       string message = "Hi there"; integer first = TRUE;
       while ((--x) >= 0) {
           if (first) first = FALSE;
           else if (!x) message += " and ";
           else message += ", ";
           message += llDetectedName(x);
       }
       llSay(PUBLIC_CHANNEL, (message = "") + message + "!");
       // Produces a message such as:
       // "Hi there, Haravikk Mistral, Strife Onizuka and Kelly Linden!"
   }
}</lsl>

Notes

To support this version of the llCastRay() implementation, please vote on SVC-6442

Deep Notes

Signature

//function void llCastRay( vector origin, vector normal, float range, integer type, list detect );