LlDetectedPos

来自人工智能助力教育知识百科
Qmf讨论 | 贡献2020年4月13日 (一) 09:39的版本 (创建页面,内容为“{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}} {{函数详情 |函数名 = Function: vector llDetectedPos( integer number ); |参数= 参数:…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

Template:Needs Translation/


函数名
Function: vector llDetectedPos( integer number );
参数:integer number–Index of detection information number does not support negative indexes.
返回值:Returns a vector that is the position (in region coordinates) of detected object number.
注意事项
注意事项
  • If number is out of bounds this function returns <0.0, 0.0, 0.0> and the script continues to execute without an error message.
  • Events that enable the llDetected* functions always return at least one detected item.
  • Detection events are not raised if there is nothing detected.[1]
  • The detection event's items detected parameter is initially never less than 1.[2]
示例
示例1
// Get position and distance of toucher
 
default
{
    touch_start(integer total_number)
    {
	// get the position of the avatar touching this prim
	vector pos = llDetectedPos(0);
 
	// compute how far away they are
	float dist = llVecDist(pos, llGetPos() );
 
	llSay(0, "You are " + (string) dist + " metres from me, at coordinates " + (string) pos);
    }
}
// get name and sim position of Avatars within "say" range

示例2

default
{
    state_entry()
    {
        llOwnerSay( "Touch me to get the positions of avatars in 'Say' range" );
    }
 
    touch_start( integer vIntTouchCount )
    {
        // Do a one-off sensor sweep over a 20m radius sphere for avatars
        llSensor( "", "", AGENT, 20, PI );
    }
 
    sensor( integer vIntFound )
    {
        integer vIntCounter = 0;
        //-- loop through all avatars found
        do
        {
            llOwnerSay( llDetectedName( vIntCounter )
                // get the position of this detected avatar
                + (string) llDetectedPos( vIntCounter ) );
        } while (++vIntCounter < vIntFound); 
    }
 
    // sensor does not detect owner if it's attached
    no_sensor()
    {
        llOwnerSay( "I couldn't find anybody" );
    }
}
相关函数
相关事件