LlListFindList/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.

要約

関数: integer llListFindList( list src, list test );

src において最初に test が出現するインデックスを integer で返します。

• list src
• list test

src において test が見つからなかった場合は -1 が返されます。
リストの先頭要素のインデックスは 0 です。
testsrc の最後のインデックスで見つかると、正のインデックスが返ります (5 つの要素の 5 番目の場合、 4) 。

警告

  • マッチングの際、データ型の一致、大文字/小文字の一致が必須です。
All Issues ~ Search JIRA for related Bugs

サンプル

list numbers = [1, 2, 3, 4, 5];
default
{
    state_entry()
    {
        integer index = llListFindList(numbers, [3]);
        if (index != -1)
        {
            list three_four = llList2List(numbers, index, index + 1);
            llOwnerSay(llDumpList2String(three_four, ","));
            // オブジェクト: 3,4
        }
    }
}
//2 つの要素をいっぺんに調べ、リストの中のパターンを見つけることもできます。
list avatarsWhoFoundMagicLeaves = ["Fire Centaur","Red Leaf"];
default
{
    state_entry()
    {
        integer index = llListFindList(avatarsWhoFoundMagicLeaves, ["Fire Centaur","Red Leaf"]);
        if (index != -1)
        {
            list output = llList2List(avatarsWhoFoundMagicLeaves, index, index + 1);
            llOwnerSay(llDumpList2String(output, ","));
            // オブジェクト: Fire Centaur, Red Leaf
        }
    }
}

便利なスニペット

ある要素がリストに含まれているかを簡単に調べるには...

if(~llListFindList(myList, (list)item))
{//存在する場合の処理をここに記述。
    // ~(-1) == 0 なので、上の条件式で問題ありません。
    // != -1 よりもバイトコードの節約となり、動作も速いです。
}

関連項目

関数

•  llSubStringIndex 他の文字列の中で文字列を検索する
•  List: Find Last Index 入力文字列でヒットした 最後の インスタンスのインデックスを表す整数値を返す
•  List: Multi-Find Index (First_or_Last) 入力文字列でマッチした要素の 全部の 最初 (または最後) のインデックスを取得する

特記事項

Search JIRA for related Issues

Signature

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