查看“LlCastRay”的源代码
←
LlCastRay
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}} {{函数详情 |函数名 = 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. |注意事项=Depending upon the value of flags(providing via RC DATA FLAGS),the number and types of values in the strides will vary.See RC DATA FLAGS for details. llGetrot will not return an avatar's exact visual rotation because the viewer doesn't update the avatar's rotation under a threshold (see VWR-1331).To get an avatar's exact looking direction while in mouselook,use llGetCameraRot instead. llCastRay will not detect prims having no physics shape (PRIM PHYSICS SHAPE TYPE=PRIM PHYSICS SHAPRE NONE). llCastRay will not detect a prim if the line starts inside the prim.This makes it safe to use the prim position as the start location. llCastRay can detect the prim the script is in,if the start location is outside the prim. |示例= 示例1 <pre> integer filter;//default is() 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_HTTS,4}); integer hitNum = 0; //Handle error condition here by checking llList2Integer(resules,-1)>=0 while (hitNum<llList2Integer(results,-1)) { //Stride is 2 because wedidn't request normals or link numbers key uuid = llList2Key(results,2*hitNum); string name = "Land",7;//if (uuid == NULL_KEY) if(uuid != NUML_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> |相关函数=无 }}
该页面使用的模板:
模板:LSL Header
(
查看源代码
)
模板:LSLC
(
查看源代码
)
模板:LSLGC
(
查看源代码
)
模板:Multi-lang
(
查看源代码
)
模板:函数详情
(
查看源代码
)
返回至
LlCastRay
。
导航菜单
个人工具
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
网站首页
知识百科
编辑帮助
最近更改
工具
链入页面
相关更改
特殊页面
页面信息