LlDetectedRot/ja

From Second Life Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

要約

関数: rotation llDetectedRot( integer number );

検出したオブジェクト number の回転を rotation で返します。

• integer number 探知情報の番号

number には 負のインデックス を使用できません。 number が検出されたオブジェクトの妥当な番号ではないとき <0.0, 0.0, 0.0, 1.0> が返ります。

仕様

llDetected* 関数はどこでも使用可能ですが、探知イベント (collision, collision_start, collision_end, sensor, touch, touch_start, touch_end) の中、または探知イベントで呼ばれた関数の中で呼び出されたときのみ使用可能な値を返します。

警告

  • number が正常なインデックス範囲を外れていても、この関数は <0.0, 0.0, 0.0, 1.0> を返し、スクリプトはエラー表示を出さずに処理を続けます。
  • llDetected* 関数が有効になるイベントは、常に少なくとも 1 個以上の探知結果を返します。
    • 何も探知されなかった場合、探知イベントは発生しません。[1]
    • 探知イベントの探知個数を表す引数は、最初は決して 1 未満にはなりません。[2]
All Issues ~ Search JIRA for related Bugs

サンプル

//--// オブジェクトにタッチしたアバターに、コンパスの針が向くようにします //--//

 //-- コンパスの方向のリスト。東から時計周りに
list gLstCompassPoints = [ "East", "NorthEast", "North", "NorthWest", "West", "SouthWest", "South", "SouthEast" ];

 //-- 回転を Z 軸中心のコンパスの方向に変換します
string CompassDirection( rotation rRotBase )
{
  integer iCountCompassPoints = llGetListLength(gLstCompassPoints);
   //-- 回転を方向に変えます
  vector vDirection = <0.0, 1.0, 0.0> / rRotBase;
   //-- 方向から、Z 軸中心の回転を算出します
  float fAngle = llAtan2(vDirection.x, vDirection.y);
   //-- 角度をから、コンパス位置を算出します
   take the angle and find the compass point
  integer iCompassPoint = llRound(fAngle * iCountCompassPoints / TWO_PI);
   //-- 文字列に変換します
  return llList2String( gLstCompassPoints, iCompassPoint );
}

default{
  state_entry()
  {
    llSay( 0, "Touch me to get your compass facing" );
  }

  touch_start( integer vIntTouchCount )
  {
    integer vIntCounter = 0;
    do
    {
      llSay( 0,
             llDetectedName( vIntCounter )
             + " is facing "
              //-- 次の行でアバターの回転を取得し、コンパスの方向に変換します
             + CompassDirection( llDetectedRot( vIntCounter ) ) );
    } while ( ++vIntCounter < vIntTouchCount );
  }
}

関連項目

記事

•  検出

特記事項

Search JIRA for related Issues

脚注

  1. ^ 例外は no_sensor ですが、ここでは llDetected* 関数は有効にはなりません。
  2. ^ 他のあらゆるイベント引数と同じように、ユーザは初期値を上書きすることができます。

Signature

function rotation llDetectedRot( integer number );
この翻訳は 原文 と比べて古いですか?間違いがありますか?読みにくいですか?みんなで 修正 していきましょう! (手順はこちら)
この項目はあなたにとって参考にならない項目ですか?もしかしたらLSL Wikiの関連した項目が参考になるかもしれません。