“LlCastRay”的版本间的差异

来自人工智能助力教育知识百科
跳转至: 导航搜索
(创建页面,内容为“{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}} {{函数详情 |函数名 = Function:list llCastRay(vector start,vector end,list options ); |参…”)
 
Ty讨论 | 贡献
 
(未显示同一用户的4个中间版本)
第3行: 第3行:
 
{{函数详情
 
{{函数详情
 
|函数名 = Function:list llCastRay(vector start,vector end,list options );
 
|函数名 = Function:list llCastRay(vector start,vector end,list options );
|参数 = 参数:vector start -starting location
+
|参数 = 参数:向量起始位置; 向量结束位置; 列表选项-可以包含任意数量的选项标志及其参数。
              vector end -ending location
+
|返回值 = 返回值:返回一个带条纹的值列表,其末尾附加一个整数状态码。
              list options -can consists of any number of option flags and their parameters.
+
 
|返回值 = 返回值:Returns a list of strided values with an additional integer status code on the end.Each stride consists of two mandatory values {key uuid,vector position}and possibly some optional values {integer link_number,vector normal}see RC DATA FLAGS for details.The status_code if it is negative is an error code,otherwise it is the number of hits (and strides)returned.
+
 
 +
|注意事项=根据标志的值(通过 rc 数据标志提供) ,strides 中的值的数量和类型将随之变化,详情请参阅 rc 数据标志。 Llgetrot 不会返回阿凡达的精确视觉旋转,因为观看者不会更新阿凡达的旋转在阈值之下(见 vwr-1331)。 想要得到阿凡达在 mouselook 的精确视角,用 llgetcamerarot 代替。 光谱检测不会检测到没有物理形状的原始物质(原始物理形状类型原始物理形状)。 如果线路从 prim 内部开始,lcastray 不会检测到 prim,这使得使用 prim 位置作为起始位置是安全的。 如果起始位置在 prim 之外,lcastray 可以检测到脚本所在的 prim。
  
  
|注意事项=
 
  
 
|示例=
 
|示例=
 
示例1
 
示例1
 
<pre>
 
<pre>
 +
integer filter;// default is 0
 +
 +
default
 +
{
 +
    state_entry()
 +
    {
 +
        string ownerName = llKey2Name(llGetOwner());
 +
        llOwnerSay("Hello, " + ownerName + "!");
 +
    }
 +
 +
    touch_start(integer total_number)
 +
    {
 +
        vector start = llGetPos();
 +
        vector end = start - <0.0, -25.0, 0.0>;
 +
 +
        if ( filter > 8 )
 +
            filter = 0;
 +
 +
        llOwnerSay("Filter " + (string)filter);
 +
 +
        list results = llCastRay(start, end, [RC_REJECT_TYPES, filter, RC_MAX_HITS, 4] );
 +
 +
        integer hitNum = 0;
 +
        // Handle error conditions here by checking llList2Integer(results, -1) >= 0
 +
        while (hitNum < llList2Integer(results, -1))
 +
        {
 +
            // Stride is 2 because we didn't request normals or link numbers
 +
            key uuid = llList2Key(results, 2*hitNum);
 +
 +
            string name = "Land"; // if (uuid == NULL_KEY)
 +
 +
            if (uuid != NULL_KEY)
 +
                name = llKey2Name(uuid);
 +
 +
            llOwnerSay("Hit " + name + ".");
 +
 +
            ++hitNum;
 +
        }
 +
 +
        ++filter;
 +
    }
 +
}
 +
       
 +
</pre>
  
 +
示例2
 +
<pre>
 +
// Fire a weapon at a target, report a hit
 +
 +
integer gTargetChan = -9934917;
 +
 +
default
 +
{
 +
    attach(key id)
 +
    {
 +
        if (id != NULL_KEY)
 +
        {
 +
            llRequestPermissions(id,PERMISSION_TAKE_CONTROLS|PERMISSION_TRACK_CAMERA);
 +
        }
 +
    }
 +
 +
    run_time_permissions (integer perm)
 +
    {
 +
        if (perm & PERMISSION_TAKE_CONTROLS|PERMISSION_TRACK_CAMERA)
 +
        {
 +
            llTakeControls(CONTROL_LBUTTON|CONTROL_ML_LBUTTON,TRUE,FALSE);
 +
        }
 +
    }
 +
 +
    control (key id, integer level, integer edge)
 +
    {
 +
        // User must be in mouselook to aim the weapon
 +
        if (level & edge & CONTROL_LBUTTON)
 +
        {
 +
            llSay(0,"You must be in Mouselook to shoot.  Type \"CTRL + M\" or type \"Esc\" and scroll your mouse wheel forward to enter Mouselook.");
 +
        }
 +
        // User IS in mouselook       
 +
        if (level & edge & CONTROL_ML_LBUTTON)
 +
        {
 +
            vector start = llGetCameraPos();
 +
            // Detect only a non-physical, non-phantom object. Report its root prim's UUID.
 +
            list results = llCastRay(start, start+<60.0,0.0,0.0>*llGetCameraRot(),[RC_REJECT_TYPES,RC_REJECT_PHYSICAL|RC_REJECT_AGENTS|RC_REJECT_LAND,RC_DETECT_PHANTOM,FALSE,RC_DATA_FLAGS,RC_GET_ROOT_KEY,RC_MAX_HITS,1]);
 +
            llTriggerSound(llGetInventoryName(INVENTORY_SOUND,0),1.0);
 +
            llSleep(0.03);
 +
            key target = llList2Key(results,0);
 +
            // Tell target that it has been hit.
 +
            llRegionSayTo(target,gTargetChan,"HIT");
 +
            // Target, scripted to listen on gTargetChan, can explode, change color, fall over .....
 +
        }
 +
    }           
 +
}
 
</pre>
 
</pre>
  
 
+
|相关函数=
 
 
 
 
 
 
 
 
|相关函数=
 
  
  
 
}}
 
}}

2020年4月19日 (日) 14:14的最新版本

Template:Needs Translation/

函数名
Function:list llCastRay(vector start,vector end,list options );
参数:向量起始位置; 向量结束位置; 列表选项-可以包含任意数量的选项标志及其参数。
返回值:返回一个带条纹的值列表,其末尾附加一个整数状态码。
注意事项
根据标志的值(通过 rc 数据标志提供) ,strides 中的值的数量和类型将随之变化,详情请参阅 rc 数据标志。 Llgetrot 不会返回阿凡达的精确视觉旋转,因为观看者不会更新阿凡达的旋转在阈值之下(见 vwr-1331)。 想要得到阿凡达在 mouselook 的精确视角,用 llgetcamerarot 代替。 光谱检测不会检测到没有物理形状的原始物质(原始物理形状类型原始物理形状)。 如果线路从 prim 内部开始,lcastray 不会检测到 prim,这使得使用 prim 位置作为起始位置是安全的。 如果起始位置在 prim 之外,lcastray 可以检测到脚本所在的 prim。
示例
示例1
integer filter;// default is 0
 
default
{
    state_entry()
    {
        string ownerName = llKey2Name(llGetOwner());
        llOwnerSay("Hello, " + ownerName + "!");
    }
 
    touch_start(integer total_number)
    {
        vector start = llGetPos();
        vector end = start - <0.0, -25.0, 0.0>;
 
        if ( filter > 8 )
            filter = 0;
 
        llOwnerSay("Filter " + (string)filter);
 
        list results = llCastRay(start, end, [RC_REJECT_TYPES, filter, RC_MAX_HITS, 4] );
 
        integer hitNum = 0;
        // Handle error conditions here by checking llList2Integer(results, -1) >= 0
        while (hitNum < llList2Integer(results, -1))
        {
            // Stride is 2 because we didn't request normals or link numbers
            key uuid = llList2Key(results, 2*hitNum);
 
            string name = "Land"; // if (uuid == NULL_KEY)
 
            if (uuid != NULL_KEY)
                name = llKey2Name(uuid);
 
            llOwnerSay("Hit " + name + ".");
 
            ++hitNum;
        }
 
        ++filter;
    }
}
        

示例2

// Fire a weapon at a target, report a hit
 
integer gTargetChan = -9934917;
 
default
{
    attach(key id)
    {
        if (id != NULL_KEY)
        { 
            llRequestPermissions(id,PERMISSION_TAKE_CONTROLS|PERMISSION_TRACK_CAMERA);
        }
    }
 
    run_time_permissions (integer perm)
    {
        if (perm & PERMISSION_TAKE_CONTROLS|PERMISSION_TRACK_CAMERA) 
        {
            llTakeControls(CONTROL_LBUTTON|CONTROL_ML_LBUTTON,TRUE,FALSE);
        }
    }
 
    control (key id, integer level, integer edge)
    {
        // User must be in mouselook to aim the weapon
        if (level & edge & CONTROL_LBUTTON)
        {
            llSay(0,"You must be in Mouselook to shoot.  Type \"CTRL + M\" or type \"Esc\" and scroll your mouse wheel forward to enter Mouselook.");
        }
        // User IS in mouselook        
        if (level & edge & CONTROL_ML_LBUTTON)
        {
            vector start = llGetCameraPos();
            // Detect only a non-physical, non-phantom object. Report its root prim's UUID.
            list results = llCastRay(start, start+<60.0,0.0,0.0>*llGetCameraRot(),[RC_REJECT_TYPES,RC_REJECT_PHYSICAL|RC_REJECT_AGENTS|RC_REJECT_LAND,RC_DETECT_PHANTOM,FALSE,RC_DATA_FLAGS,RC_GET_ROOT_KEY,RC_MAX_HITS,1]);
            llTriggerSound(llGetInventoryName(INVENTORY_SOUND,0),1.0);
            llSleep(0.03);
            key target = llList2Key(results,0);
            // Tell target that it has been hit. 
            llRegionSayTo(target,gTargetChan,"HIT");
            // Target, scripted to listen on gTargetChan, can explode, change color, fall over .....
        }
    }            
}
相关函数
相关事件